Android Studio를 사용하고 있습니다.부팅시 실행되는 디버그 앱
수신인이 android.intent.action.BOOT_COMPLETED를 수신하는 앱용 BroadcastReceiver를 추가 한 경우 수신자는 테스트 용 토스트 만 표시합니다. 문제는 안드로이드가 시작된 직후에 "App has stopped"이라는 메시지가 나타납니다.
내 첫 번째 질문은 : 어쨌든 시작할 때 디버깅하고 어디에서 문제가 있는지 확인하는 것입니까? Android Studio에서 해당 문제를 언급하는 로그를 볼 수 없기 때문입니다.
두 번째 질문은 문제 자체와 관련이 있습니다. 여기 코드는 다음과 같습니다 XML :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="myapp">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<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">
<activity android:name="MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name=".AutoStartReceiver"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>
자바 : 브로드 캐스트 리시버
public class AutoStartReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "loaded", Toast.LENGTH_LONG).show();
throw new UnsupportedOperationException("Not yet implemented");
}
}
세 번째 질문 : 그것은 OK 수신기의 일부 무거운 작업합니다 (알람 관리기를 일부 파일을 읽고 설정)을 수행하는 서비스를 만드는 것보다? API 26에서 Android는 서비스에 많은 제약을 가하고 있기 때문입니다.
당신에게 두 번째 장치는 대개 자체가 부팅 할 응용 프로그램 전에 발생 디버깅 연결을 가져옵니다 디버깅 할 수 부팅 시작
, 즉 그 것이었다. Android 시작시로드 될 때 로그가 비어 있지만 앱 로그를 가져올 수 없습니다. – hiddeneyes02