问题
This problem related to this question
send and receive sms to verify mobile number
I have unlocked samsung at&t device. I am trying to send message by code. But my code is not working so i connected my device with USB and track whats the problem is. I found that i am getting this exception
981/? 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:13175)
at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:2044)
at com.android.providers.settings.SettingsProvider.callFromPackage(SettingsProvider.java:615)
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)
07-05 00:53:08.676 2411-2981/? W/ActivityManager﹕ 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
07-05 00:53:08.691 22617-22617/com.keepAeye.gps E/code is﹕ 29514
I added these permission in my manifest file
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS"/>
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL"/>
But still not working.
What should i do now?
I know there is several posts on this site about this issue but none of them helping me.
UPDATE
Here is my code to send message
private void sendSMS1(String phoneNumber, String message)
{
String SENT = "SMS_SENT";
String DELIVERED = "SMS_DELIVERED";
PendingIntent sentPI = PendingIntent.getBroadcast(this, 0,
new Intent(SENT), 0);
PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0,
new Intent(DELIVERED), 0);
//---when the SMS has been sent---
registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context arg0, Intent arg1) {
switch (getResultCode()) {
case Activity.RESULT_OK:
Toast.makeText(getBaseContext(), "SMS sent",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
Toast.makeText(getBaseContext(), "Generic failure",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
Toast.makeText(getBaseContext(), "No service",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
Toast.makeText(getBaseContext(), "Null PDU",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
Toast.makeText(getBaseContext(), "Radio off",
Toast.LENGTH_SHORT).show();
break;
}
}
}, new IntentFilter(SENT));
//---when the SMS has been delivered---
registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context arg0, Intent arg1) {
switch (getResultCode()) {
case Activity.RESULT_OK:
Toast.makeText(getBaseContext(), "SMS delivered",
Toast.LENGTH_SHORT).show();
break;
case Activity.RESULT_CANCELED:
Toast.makeText(getBaseContext(), "SMS not delivered",
Toast.LENGTH_SHORT).show();
break;
}
}
}, new IntentFilter(DELIVERED));
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage("9501921***", null, "hello", sentPI, deliveredPI);
}
It's always going to generic failure. Don't know why.
回答1:
To be able to hold INTERACT_ACROSS_USERS
, your app has to be signed by the firmware's signing key or it has to be installed on the system partition.
To be able to hold INTERACT_ACROSS_USERS_FULL
, your app has to be signed by the firmware's signing key.
Ordinary applications are not signed by the firmware's signing key, as that is for device manufacturers and those writing custom ROMs. Ordinary applications are not installed on the system partition, as that is for device manufacturers, those writing custom ROMs, and those who root their devices.
It is unclear why you think that the messages you show in your question pertain to your app. If you are sure that they do, you will need to determine what it is about your code that is triggering those messages, and then fix that code.
来源:https://stackoverflow.com/questions/31224640/this-requires-android-permission-interact-across-users-full