发送不受保护的广播 com.motorola.motocare.INTENT_TRIGGER java.lang.Throwable [英] Sending non-protected broadcast com.motorola.motocare.INTENT_TRIGGER java.lang.Throwable

查看:30
本文介绍了发送不受保护的广播 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.

这是我的清单文件:-

<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>

每当我关闭导航抽屉时 SettingsActivity 出现在前台,这是我使用此代码设置警报的活动:-

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);
}

我的日志文件如下:-

03-13 10:12:48.253 1576-22821/?E/ActivityManager:从系统 4512:com.motorola.process.system/1000 pkg com.motorola.motgeofencesvc 发送不受保护的广播 com.motorola.motocare.INTENT_TRIGGERjava.lang.Throwable在 com.android.server.am.ActivityManagerService.broadcastIntentLocked(ActivityManagerService.java:18226)在 com.android.server.am.ActivityManagerService.broadcastIntent(ActivityManagerService.java:18826)在 android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:512)在 com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2906)在 android.os.Binder.execTransact(Binder.java:565)

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)

推荐答案

如果您在 AndroidManifest.xml 中声明了 "android:sharedUserId="android.uid.system",然后声明受保护的广播.

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" />

您可以使用 Android Studio 进行构建.

这篇关于发送不受保护的广播 com.motorola.motocare.INTENT_TRIGGER java.lang.Throwable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆