我在堆栈溢出时搜索了不同的答案。即使我禁用服务和广播接收器,它也会显示错误。
这是我的清单文件: -
<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
显示为前景,这是我使用此代码设置闹钟的活动: -
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.motocare.INTENT_TRIGGER:com.motorola.process.system / 1000 pkg com.motorola.motgeofencesvc java.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)
答案 0 :(得分:4)
如果您的 AndroidManifest.xml 已声明"android:sharedUserId="android.uid.system"
,则声明受保护的广播。
<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进行构建。
答案 1 :(得分:0)
我只是忽略了这个错误,在ZTE Axon 7上似乎无关紧要。一定与操作系统搞砸有关。