Closed mwarnett closed 7 years ago
fixed
I was not sure what to expect now as this was just marked fixed, but I don't consider this fixed.
On Android 6 it no loner asks me to allow phone access but the Phone permission is still there even though I did not include it. It seems to be OFF so I guess that is OK.
On Android 4.4.2 when I go to update my app which previously just had Storage I am told the app now also needs phone access. I did not request phone access. I cannot install the upgrade unless I allow the Phone permission.
This is a very sensitive issue for me. It seems that every time I go to update an Android app is needs more and more permissions. I often end up removing an app that demands permissions there is no logical reason for.
Now my own apps are doing it.
I do not use the phone, this should not be required.
I think this might not be us but rather google play services. Try adding the build hint android.playService.ads=false
which will disable all googleplay services. Unless you use location or in app purchase this shouldn't have an impact on your app.
I am still having this problem.
Here is a sample program:
`package com.mycompany.myapp;
import com.codename1.ui.AutoCompleteTextField; import com.codename1.ui.Button; import com.codename1.ui.Dialog; import com.codename1.ui.Display; import com.codename1.ui.Form; import com.codename1.ui.Toolbar; import com.codename1.ui.plaf.UIManager; import com.codename1.ui.util.Resources; import com.codename1.io.Log; import com.codename1.media.Media; import com.codename1.media.MediaManager; import com.codename1.ui.Command; import com.codename1.ui.events.ActionEvent; import com.codename1.ui.events.ActionListener; import com.codename1.ui.layouts.BorderLayout;
import java.util.Vector;
/**
of building native mobile applications using Java. */ public class MyApplication implements ActionListener {
private Form current; private Resources theme; private Command _backCommand;
public void init(Object context) { theme = UIManager.initFirstTheme("/theme");
// Enable Toolbar on all Forms by default
Toolbar.setGlobalToolbar(true);
// Pro only feature, uncomment if you have a pro subscription
// Log.bindCrashProtection(true);
}
public void start() { if(current != null){ current.show(); return; }
Form sampleForm = new Form("Sample App");
sampleForm.setLayout(new BorderLayout());
Button button = new Button("Play");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
Media beep = MediaManager.createMedia("http://www.readerware.com/images/beep.mp3", false);
beep.play();
}
catch (Exception exception) {
}
}
});
sampleForm.add(BorderLayout.CENTER, button);
sampleForm.show();
}
public void stop() { current = Display.getInstance().getCurrent(); if(current instanceof Dialog) { ((Dialog)current).dispose(); current = Display.getInstance().getCurrent(); } }
public void destroy() { }
public void actionPerformed(ActionEvent actionEvent) { Command command = actionEvent.getCommand();
if (command == _backCommand) {
stop();
Display.getInstance().exitApplication();
return;
}
} }
I build the above with the following build hints:
android.min_sdk_version=9 android.playService.ads=false android.xpermissions=android.permission.INTERNET,android.permission.WRITE_EXTERNAL_STOR
When I install it on an Android device it needs:
Read phone status and identity Modify or delete the contents of your SD card. Read the contents of your CD card Full network access
If I comment out the two lines in actionPerformed it does not need the phone permission.
`
It's possible that this is triggered because you are using Ant and not Gradle. We shifted all our effort to Gradle as Google deprecated ant quite a while back. I think Play allows you to submit different APK's for different OS/Device combinations. Maybe that could be a good strategy if you really want to support the users remaining on older devices.
I am not using Ant in this case, just the build hints mentioned above. This was built with the default Gradle build
I'll try to reproduce this.
The AndroidGradleBuilder explicitly adds the phone permission if any classes in the com.codename1.media
package are used.
Any idea why this is necessary? @chen-fishbein @codenameone
I have just removed this from the builder (now it won't add the phone permission simply because the media package is used). Seems to work ok on my Nexus 5 so far.
@shannah this is necessary for the background sound playback mode. If a call comes in Android devices would keep playing sound during the phonecall unless you detect incoming calls and stop media playback (seriously). I think there is a build flag to disable that feature maybe it should be on by default.
This is an old behavior which was fixed, we are now responding to the media focus. (see Audio#onAudioFocusChange). We don't need this permission anymore, I am guessing I fixed the code without fixing the permission in the gradle script.
I just added Media & MediaManager to play sound in my app. All I am doing is playing a beep to alert the user to an issue.
I did not change my android.xpermissions as there does not seem to be one related to sound.
When I installed the new version on a device running Android 4.4.2 I was told that my app needed new permissions to read phone status and identity.
When I installed the app on a device running Android 6.0.1 the install went normally but when the app went to play the sound I am asked if I want to allow the app to place phone calls.
All I am doing is playing a stupid beep (Why isn't that in CodenameOne?), I do not need phone access and don't want my app to require it. I asked about this on the forums. Shai responded: