I'm having issues with my prototype application. It works fine between two emulators on my PC, but when I install it on my phone it won't send text messages or even care to ask for the permission (if that is the issue).
Furthermore, I'm recieving the same error no matter what I do, on app start, each time I press a button and on every new intent start:
E/DatabaseUtils: Writing exception to parcel
java.lang.SecurityException: Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL
at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:13140)
at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:2038)
at com.android.providers.settings.SettingsProvider.callFromPackage(SettingsProvider.java:607)
at android.content.ContentProvider$Transport.call(ContentProvider.java:279)
at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:273)
at android.os.Binder.execTransact(Binder.java:388)
at dalvik.system.NativeStart.run(Native Method)
I've been looking at a lot of similar issues, and I did add
uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" android:protectionLevel="signature"/>
to my manifest, but nothing seems to work for me.
The real odd thing to me is that the error occurs on application start, because nothing interesting really seems like nothing interesting is happening at that point:
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
// Go to contact list
public void onClick(View view) {
Intent i = new Intent(this,AddContact.class);
startActivity(i);
}
public void onGPS(View view) {
Intent j = new Intent(this,GPSActivity.class);
startActivity(j);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
Any ideas ?
The issue is seemingly with Samsung Galaxy S3. The link: Permission Denial: this requires android.permission.INTERACT_ACROSS_USERS_FULL
Provided by Sumighosh Chaurvil explains the problem; And that there's really not much to do about it.
I installed the application on another phone, and it works with no problems whatsoever!
Related
What it's suppose to do is turn on location when needed and turn off location when not needed. I am having trouble with my Location Service when I tap to turn on location service it says, "app has stopped" please find my logcat below. any help is truely appreciated. Thank You
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.kenpar.dmsassign2, PID: 21749
java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.location.GPS_ENABLED_CHANGE from pid=21749, uid=10184
at android.os.Parcel.readException(Parcel.java:1472)
at android.os.Parcel.readException(Parcel.java:1426)
at android.app.ActivityManagerProxy.broadcastIntent(ActivityManagerNative.java:2640)
at android.app.ContextImpl.sendBroadcast(ContextImpl.java:1499)
at android.content.ContextWrapper.sendBroadcast(ContextWrapper.java:377)
at com.kenpar.dmsassign2.LocationActivity$1.onClick(LocationActivity.java:30)
at android.view.View.performClick(View.java:4633)
at android.view.View$PerformClick.run(View.java:19274)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5593)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Application terminated.
Location java code:
public class LocationActivity extends Activity {
Button onLoc;
Button offLoc;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_location);
onLoc = (Button)findViewById(R.id.onLoc);
offLoc = (Button)findViewById(R.id.offLoc);
onLoc.setOnClickListener(new OnClickListener(){
public void onClick (View view){
Intent intent = new Intent ("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", true);
sendBroadcast(intent);
}
});
offLoc.setOnClickListener(new OnClickListener(){
public void onClick (View view){
Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", false);
sendBroadcast(intent);
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.location, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
On android version 4.4 and above you cannot manually turn location services on and off. It will throw a securityException and can only be done manually. What you can do, you can move the user to the location services settings screen when location services are required by firing this intent:
startActivity(context, new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
Am using the Google+ login feature in my app. The Login functionality is in my LoginActivity, and the logout functionality is called from another activity, an Activity containing Fragments. To be able to call the logout method, the Activity containing the Fragments extends the Login Activity(else the app crashes). These methods are in the Login Activity:
// Initializing google plus api client (from onCreate method of Login Activity)
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this).addApi(Plus.API)
.addScope(Plus.SCOPE_PLUS_LOGIN).build();
//Called when a connection is successful
public void onConnected(Bundle arg0) {
mSignInClicked = false;
Toast.makeText(this, "User is connected!", Toast.LENGTH_LONG).show();
//Get user's information
getProfileInformation();
Intent intent = new Intent(getApplicationContext(), UtilityActivity.class);
startActivity(intent);
}
When I run the app, the Toast is never dismissed.When I comment out the toast and run the app again, none of the widgets respond. Am thinking the app stays in an onConnected state?.
I don't know why this happening, but am suspecting it's because am calling the onCreate method or the onConnected method twice?
The call to signout is being made from the onOptionsItemsSelected method of the Activity containing the Fragments like this:
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
switch (id) {
case R.id.action_settings:
Toast.makeText(getApplicationContext(), "Settings selected", Toast.LENGTH_LONG).show();
return true;
case R.id.action_logout:
signOutFromGooglePlus();
return true;
case R.id.action_revoke_access:
revokeGplusAccess();
return true;
}
Method called when the signin button is clicked:
private void signInWithGooglePlus() {
if (!mGoogleApiClient.isConnecting()) {
mSignInClicked = true;
resolveSignInError();
}
}
You mention that the issue is occurring in UtilityActivity, which is launched by LoginActivity in onConnect().
Your likely issue (without seeing the code in UtilityActivity) is that UtilityActivity does not have a reference to the connected GooogleApiClient from LoginActivity. So, while you have a valid connection in LoginActivity, you do not in UtilityActivity. Remember, extending LoginActivity doesn't mean you share its fields. It's more like sharing code w/o having to copy/paste.
There are several options on how to proceed - pass a copy of mGoogleApiClient in the Intent that launches UtilityActivity, make the activity that controls login/logout a service that all your other activities can use, pass only the information that UtilityActivity needs in an Intent when launched, have each Activity manage their GoogleApiClient connections directly...
I am trying to implement an android simple code that uses proximityalerts and gives an alert when entering and exiting some defined area
the code runs without errors but i would like to test if it works with coordinates (first not in the area, then goes in should receive an alert, then exits and receive another alert) so i googled how to use telnet to give lat,long but all i found is giving fixed values
is there another way to approach this?
PS: I am using android studio :)
EDIT: i figured out how to change the coordinates and i followed a tutorial to get proximity test ... the code runs without any errors but the intent to give the alert does not seem to fire
here is my code:
MainActivity
public class MainActivity extends ActionBarActivity {
LocationManager lm;
double lat=32.001271,long1=35.950375; //Defining Latitude & Longitude
float radius=100; //Defining Radius
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lm=(LocationManager) getSystemService(LOCATION_SERVICE);
Intent i= new Intent("com.example.hala.proximityalert"); //Custom Action
PendingIntent pi = PendingIntent.getBroadcast(getApplicationContext(), -1, i, 0);
lm.addProximityAlert(lat, long1, radius, -1, pi);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
ProximityReceiver
public class ProximityReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context arg0, Intent arg1) {
// TODO Auto-generated method stub
// The reciever gets the Context & the Intent that fired the broadcast as arg0 & agr1
String k=LocationManager.KEY_PROXIMITY_ENTERING;
// Key for determining whether user is leaving or entering
boolean state=arg1.getBooleanExtra(k, false);
//Gives whether the user is entering or leaving in boolean form
if(state){
// Call the Notification Service or anything else that you would like to do here
Toast.makeText(arg0, "Welcome to my Area", Toast.LENGTH_LONG).show();
}else{
//Other custom Notification
Toast.makeText(arg0, "Thank you for visiting my Area,come back again !!", Toast.LENGTH_LONG).show();
}
}
}
so if anyone has an idea on why it doesn't fire i would really appreciate the help
You can give coordinates via :
Eclipse -> DDMS -> Emulator Control tab -> Give coordinate includes
latitude and longitude
I am following the Android by Udacity course, but by pressing the refresh button to retrieve the json that error appears in my logcat, what could be happening, putting this permission in manifest.xml not resolved ....I'm using Galaxy S3 device.
java.lang.SecurityException: Permission Denial: get/set setting for user asks to run as > user -2 but is calling from user 0;this requires >android.permission.INTERACT_ACROSS_USERS_FULL
#Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_refresh) {
FetchWeatherTask tempoTask = new FetchWeatherTask();
tempoTask.execute("87047100");
return true;
}
return super.onOptionsItemSelected(item);
}
try adding this in your manifest file:
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL"/>
hope it helps
My goal is to support a functionality that mute phone (possibly with vibrations enabled/disabled), so when a call or sms is received it won't make noise
unmute phone but prompt for "password for unmute".
And this remains valid for any other application, that it ask for password entry before unmute...
How can I do this? What permissions are required in AndroidManifest?
Previously on Stackoverflow, Android mute/unmute phone.
Those answers discuss both permissions and the coding. Also, tasker can handle everything you're looking to do.
And here's a link to a tutorial.
The code below runs fine in the emulator. When you run it, you can see the mute goes on in the notification area. In addition to the code, I had to add the (uses) permission for android.permission.MODIFY_AUDIO_SETTINGS.
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
AudioManager audio = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
audio.setRingerMode(AudioManager.RINGER_MODE_SILENT);
return true;
}