<1>插上USB后,
<2>程序自动启动,
<3>自动出现通知栏,
<4>自动返回桌面,
<5>点击通知栏里程序图标可以返回程序界面我的实现方式是:自定义一个广播,程序启动时,发送广播,在BroadcastReceiver进行逻辑操作,具体代码如下:
public class ApplicationStartReceiver extends BroadcastReceiver
{        private Context mContext;
        private Intent mIntent;
        private boolean flag = true;        public void onReceive(Context context, Intent intent)
        {                this.mContext = context;
                this.mIntent = intent;                showNotification();
                if (flag)
                {
                        getHome();
                        flag=false;
                }
        }        public static final int NOTIFICATION_ID = 10001;        // 显示一个通知
        public void showNotification()
        {
                // 创建一个通知
                Notification notification = new Notification(drawable.tttt,
                                "守护精灵", System.currentTimeMillis());
                // 将此通知放到通知栏的"正在运行"组中
                notification.flags |= Notification.FLAG_ONGOING_EVENT;
                PendingIntent contentIntent = PendingIntent.getActivity(mContext, 0,
                                new Intent(mContext, UAppAssistantDeamon.class), 0);
                notification.setLatestEventInfo(mContext, "守护精灵",
                                "守护精灵,点击启动前台……", contentIntent);
                NotificationManager notificationManager = (NotificationManager) 
                                mContext.getSystemService(android.content.Context.NOTIFICATION_SERVICE);
                notificationManager.notify(NOTIFICATION_ID, notification);        }
        public void getHome()
        {
                Intent i = new Intent(Intent.ACTION_MAIN);
                i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                i.addCategory(Intent.CATEGORY_HOME);
                startActivity(i);
        }
}我实现的时候有一个问题是,启动程序后,是出现了通知栏,也返回桌面了 ,但是点击通知栏里的程序图标,进不去程序了求指点呀
Android自动