Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
606 views
in Technique[技术] by (71.8m points)

android - Sending non-protected broadcast com.motorola.motocare.INTENT_TRIGGER java.lang.Throwable

I have searched different answers on stack overflow. It shows the error even if I disable the services and broadcast receivers.

This is my Manifest file:-

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.appzoy.croatiaapp">

<!-- to make api calls -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<!-- for qr code scanning -->
<uses-permission android:name="android.permission.CAMERA" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    android:fullBackupContent="@xml/backup_descriptor">
    <activity
        android:name=".MainActivity" />
    <activity android:name=".LoginActivity" />
    <activity
        android:name=".TicketsListActivity"
        android:theme="@style/AppTheme.NoActionBar"
        android:windowSoftInputMode="stateHidden" />
    <activity android:name=".SplashActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".SettingsActivity"
       android:theme="@style/AppTheme.NoActionBar"></activity>
    <receiver android:name=".receivers.AlarmReceiverSubmit"
        android:exported="false"
        android:enabled="true"/>

    <service android:name=".services.AlarmService"
        android:exported="false"
        android:enabled="true"/>

    <receiver android:name=".receivers.NetworkChangeReceiver"
        android:exported="false"
        android:enabled="true">
        <intent-filter>
            <action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
        </intent-filter>
    </receiver>
</application>

Whenever I close the navigation drawer SettingsActivity appears to foreground and this is the activity where I set the alarm using this code:-

 private void setAlarm(Calendar calSet) {

    Toast.makeText(this, "Alarm is set @ " + calSet.getTime(), Toast.LENGTH_SHORT).show();

    Intent intent = new Intent(getBaseContext(), AlarmService.class);
    PendingIntent pendingIntent = PendingIntent.getService(getBaseContext(), 1, intent, 0);
    AlarmManager alarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
    alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, calSet.getTimeInMillis(),AlarmManager.INTERVAL_DAY, pendingIntent);
}

private void setAlarmSubmitTickets(Calendar calSet) {

    Toast.makeText(this, "Alarm is set @ " + calSet.getTime(), Toast.LENGTH_SHORT).show();

    Intent intent = new Intent(getBaseContext(), AlarmReceiverSubmit.class);
    intent.putExtra("selectedTime", txtSendTicketsTime.getText().toString());
    PendingIntent pendingIntent = PendingIntent.getBroadcast(getBaseContext(), 1, intent, 0);
    AlarmManager alarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
    alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calSet.getTimeInMillis(),AlarmManager.INTERVAL_DAY, pendingIntent);
}

And my Log file is as follows :-

03-13 10:12:48.253 1576-22821/? E/ActivityManager: Sending non-protected broadcast com.motorola.motocare.INTENT_TRIGGER from system 4512:com.motorola.process.system/1000 pkg com.motorola.motgeofencesvc java.lang.Throwable at com.android.server.am.ActivityManagerService.broadcastIntentLocked(ActivityManagerService.java:18226) at com.android.server.am.ActivityManagerService.broadcastIntent(ActivityManagerService.java:18826) at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:512) at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2906) at android.os.Binder.execTransact(Binder.java:565)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you have in your AndroidManifest.xml declared "android:sharedUserId="android.uid.system", then declare the protected broadcast.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yourcompany.mypackage"
android:sharedUserId="android.uid.system">

<uses-sdk
    android:minSdkVersion="17"
    android:targetSdkVersion="24" />

<protected-broadcast android:name="com.motorola.motocare.INTENT_TRIGGER" />

You can build with Android Studio.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...