하나는 내게 안드로이드 개발에 새로운 도움을 청합니다. 부팅하는 동안 브로드 캐스트 레코더에 전화하고 싶습니다. 그러나 그것은 나의 소스 코드를 내가 매니페스트부팅하는 동안 BroadcastReceiver를 호출하는 방법?
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tajmirkhan.broadcasetreciver_new">
<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=".Bootservice" android:exported="true" android:enabled="true">
<intent-filter android:priority="500">
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
</application>
</manifest>
의 권한을 부여
working.here이며,이 사람은 내 브로드 캐스트 리시버 클래스
public class Bootservice extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.e("dd","above the onReceive mthode");
if(intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)){
Toast.makeText(context, "boot completed ", Toast.LENGTH_SHORT).show();
Log.e("dd","inisde the onReceive mthode");
}
}
}
이가 내 mainActivity
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.e("dd","oncreat ");
}
}
는
내가이 코드 조각을 적용하지만이 작동하지 않았다. –