![](/bink.gif) |
|
| ![](/bink.gif) |
booting ÈÄ¿¡ ÀÚµ¿À¸·Î ½ÇÇà µÇ´Â app ¸¸µé±â |
|
|
![](icon/private_name/1.gif) |
8³â Àü |
Android Booting ÈÄ¿¡ boot complete intent¸¦ ¹Þ¾Æ ÀÚµ¿À¸·Î ½ÇÇàÇÑ´Ù.
1. AndroidManifest.xml
<manifest package="com.pinkrabbit.pinkusbplayer"
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true">
<activity
android:name="PinkUsbPlayerActivity"
android:label="@string/app_name"
android:exported="true"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="UsbPlayerService" android:enabled="true">
<category android:name="android.intent.category.DEFAULT" />
</service>
<receiver android:name=".StartPlayReceiver"
android:enabled="true"
android:exported="false"
android:label="StartPlayReceiver"
>
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>
¼³¸í : receiver¿¡¼ intent-filter¸¦ ¼³Á¤ÇÏ¿© BOOT_COMPLETED intent ¹Þµµ·Ï ¼³Á¤Çϸé, BOOT_COMPLETED intent¸¦ ¹ÞÀ¸¸é receiverÀÇ onReceive °¡ ½ÇÇàÀ̵ȴÙ.
2. Java ¼Ò½º¿¡¼ BroadcastReceiver ¸¦ »ó¼Ó¹Þ¾Æ class »ý¼ºÇÑ´Ù.
package com.pinkrabbit.pinkusbplayer;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Environment;
import android.os.SystemClock;
import android.util.Log;
/**
* Created by pinkrabbit on 2016-01-07.
*/
public class StartPlayReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.e("StartPlayReceiver","start service~~");
if(action.equals("android.intent.action.BOOT_COMPLETED")) {
Intent i = new Intent(context, UsbPlayerService.class);
context.startService(i);
}
}
}
¼³¸í : BOOT_COMPLETED actionÀ» ¹ÞÀ¸¸é service¸¦ ½ÇÇà Çϵµ·Ï ±¸ÇöÇÏ¿´´Ù. |
|
̵̧ : 298 |
̵̧
¸ñ·Ï
|
|
| ![](/bink.gif) |
|