내가 알고 있는 이 질문은 물었 많은 사이트에서 그러나 나는 것 같 솔루션을 찾을 수 있습니다. 내 BOOT_COMPLETED 수신기가 호출되지 않은 경우 응용 프로그램이 실행되고 있지 않습니다.
Manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.startuptest"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="internalOnly">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.startuptest.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="com.example.startuptest.StartUpBootReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>
StartUpBootReceiver:
public class StartUpBootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d("startuptest", "StartUpBootReceiver " + intent.getAction());
if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
Log.d("startuptest", "StartUpBootReceiver BOOT_COMPLETED");
}
}
}
응용 프로그램을 실행하는 경우 및 시뮬레이션으로 전화
adb shell
am broadcast -a android.intent.action.BOOT_COMPLETED
이벤트이 제대로 수신,그러나,경우 응용 프로그램을 닫 이벤트지 않을 받으며,그것을 받은에서 시작합니다.
나는 응용 프로그램을 설치한 다음 시작했다 몇 번을 확인이 등록되어 있습니다. 나는'm pretty 손실이 하나도록 모든 조언을 높게 평가될 것입니다.
편집:에서 볼 수 있는 로그를 다른 모든 폐쇄 응용 프로그램(유튜브,FileObserver,etc.)을 받 boot_completed 이벤트,그냥 내 없습니다.
을 시작으로*안드로이드 3.1모든 응용 프로그램 설치시,는 배치에서 a"중**"상태입니다.(이것은 동일한 상태는 응용 프로그램에서 끝난 후에는 사용자의 힘이-중지에서 응용 프로그램을 설정 응용 프로그램입니다.)
동"중"상태응용 프로그램 실행되지 않습니다 어떤 이유로든의한 경우를 제외하고,매뉴얼의 시작하는 활동입니다. (없음을 의미BroadcastReceviers
(ACTION_PACKAGE_INSTALLED
,BOOT_COMPLETED
등) 호출에 관계없이의 이벤트는 등록때까지 사용 수동으로 응용 프로그램.)
이 안티-멀웨어에 의해 이동 Google. 구글이 주장하는 사용자 실행해야에 있는 활동을 실행하기 전에 먼저 응용 프로그램 갈 수 있습니다. 을 방지하BOOT_COMPLETED
에서 전달되는 것까지 활동이 시작되는 것은 논리적의 결과입니다.
이것에 대해 더 자세한 정보: http://developer.android.com/about/versions/android-3.1.html#launchcontrols http://commonsware.com/blog/2011/07/05/boot-completed-regression.html http://devmaze.wordpress.com/2011/12/05/activating-applications/
나는 내 때 응용 프로그램 BOOT_COMPLETED,그래서 나는 그것을 알's 니다. 추가Log.d
상't show. 추가토스트
표시. 작 differents 에 Manifest.xml
<receiver android:name="com.example.startuptest.StartUpBootReceiver" android:enabled="true" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
각 대답을 여기에 추가 작은 조각의 정보를,그래서 여기입니다 요약의 모든 것:
하는지 확인을 받을 것이 BOOT_COMPLETED 있는지 확인해 다음을 수행할 수 있습니다.
<receiver 안드로이드:이름="com.yourpacakge.BootReceiver"안드로이드:수출="true"안드로이드:enabled="true"> <적으> <안드로이드 액션:이름="이다.니다.작업입니다.BOOT_COMPLETED"/> <category:안드로이드 이름="이다.니다.카테고리입니다.기본값"/> </적으> </수신기> 2. 추가 권한:
<안드로이드 권한 사용:name="이다.권한이 있습니다.감"/>
HeresC#버전 경우에 당신은 그것을 원한다. 나의 테스트는 그것을 아주 많이 완벽하고 시작은 매우 빠르다. 지만 참고 있는 추가 모두C#고서AndroidManifest.xml휴식 그것은(나도).
또한 추가 몇 가지 좋은하고 유용한 예고 싶다고 했다 발견 밖으로 누구에게서 배우는 대신 그것은 나 자신을 읽을 때를 통해 다큐멘터리다.
[BroadcastReceiver(Enabled = true, Exported = true, DirectBootAware = true, Name = "com.nevaran.startup.StartUpBootReceiver")]
[IntentFilter(new string[] {
Intent.ActionBootCompleted
, Intent.ActionLockedBootCompleted
, Intent.ActionMyPackageReplaced
, Intent.ActionUserInitialize
, "android.intent.action.QUICKBOOT_POWERON"
, "com.htc.intent.action.QUICKBOOT_POWERON"
})]
public class BootReceiver : BroadcastReceiver
{
public override void OnReceive(Context context, Intent intent)
{
if( intent.Action.Equals(Intent.ActionBootCompleted)
|| intent.Action.Equals(Intent.ActionLockedBootCompleted)
|| intent.Action.Equals(Intent.ActionUserInitialize)
|| intent.Action.Equals("android.intent.action.QUICKBOOT_POWERON")
|| intent.Action.Equals("com.htc.intent.action.QUICKBOOT_POWERON")
)
{
//run code here only if its started by the chosen actions
}
//some code that doesnt care about which action is triggered by
}
}
이 문제를 해결하려면 사용할 수 있습니다 firebaseJobDispatcher 호출을 자동으로 firebaseJobDispatcher 이 있는 코드를 민감하는 귀하의 서비스 예정 시간 후에 서비스 중지에 의 OS,하지만 당신의 firebaseJobDispatcher 이 다시 활성화됩니다.귀하의 서비스. FirebaseJobDispatcher 속성을 많이 가지고있는 곳에서 당신의 범위를 정의 이;
작동 방법에 대한 더 자세히 https://github.com/firebase/firebase-jobdispatcher-android
를 알고 싶은 경우 실제 이 뒤에 이유 BOOT_COMPLETE 작동하지 않거나 받지 않. 나는 당신을 제안합니다 공 안드로이드 개발하는 사이트입니다. 그들은 설명했다 정확한 솔루션입니다.
기본적으로 필요하신 안드로이드:enabled="true"안드로이드:수출="true"플래그에는 매니페스트에 나타날 방송된다.
<receiver android:name=".bootReceiver" android:enabled="true" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</receiver>