アプリケーションのインストール時にサウンドを鳴らしたい。アプリケーションでブロードキャストレシーバーを使用してこれを試しました。ブロードキャスト レシーバーでは、メディア プレーヤーを開始するサービスを実行しています。しかし、ブロードキャストレシーバーの受信方法に入ることができません。しかし、別のアプリをインストールしようとすると、イベントが発生します。私のアプリでのみイベントを取得する方法。マニフェスト ファイルの私の権限
<uses-permission android:name = "android.permission.INSTALL_PACKAGES"/>
    <uses-permission android:name="android.permission.RESTART_PACKAGES"/>
<receiver android:name=".DemoReceiver" >
        <intent-filter >
            <action android:name="android.intent.action.PACKAGE_ADDED" />
            <action android:name="android.intent.action.PACKAGE_INSTALL" />
             <action android:name="android.intent.action.PACKAGE_CHANGED" />
              <action android:name="android.intent.action.PACKAGE_RESTARTED" />               
    <action android:name="android.intent.action.PACKAGE_REPLACED"/>
    <action android:name="android.intent.action.USER_PRESENT"/>
    <data android:scheme="package"/>
        </intent-filter>
    </receiver>
そして放送受信機で
import android.content.BroadcastReceiver;
android.content.Context をインポートします。android.content.Intent をインポートします。
public class DemoReceiver extends BroadcastReceiver {
     @Override
     public void onReceive(final Context context, final Intent bootintent) {
         System.out.println("entered broadcast receiver");
           if(bootintent.getAction() != null)
         {               
              context.startService(new Intent(context, DemoService.class));
         }
     }
     }
そしてサービスは
public class DemoService extends Service {
 MediaPlayer player;
 private class LogTask extends TimerTask {
  public void run() {
   Log.i(LOGTAG, "scheduled");
  }
 }
 private LogTask mLogTask;
 @Override
 public IBinder onBind(final Intent intent) {
  return null;
 }
 @Override
 public void onCreate() {
  super.onCreate();
  Log.v("StartServiceAtBoot", "StartAtBootService Created");
  player=MediaPlayer.create(this, R.raw.sirensound);
  player.setLooping(false);
 }
 public void onStart(Intent intent, int flags, int startId) {
       Log.v("StartServiceAtBoot", "StartAtBootService -- onStartCommand()");        
       player.start();
      }
 @Override
      public void onDestroy() {
            super.onDestroy();
            Log.v("StartServiceAtBoot", "StartAtBootService Destroyed");
      }
}