简体   繁体   English

使Android应用自动启动

[英]make an android app autostart

Is it possible to make an installed app auto start itself? 是否可以使已安装的应用程序自动启动?

thanks 谢谢

Yes . 是的。

For this you have to use Alarm Notification . 为此,您必须使用“警报通知”。

You can found many tutorial for this on Net. 您可以在网上找到许多有关此的教程。 Just google it.. 只是谷歌。

You will found code something like this... 您会发现类似这样的代码...

            Intent intent = new Intent(FirstScreen.this, MyBroadcastListener.class);

            PendingIntent sender = PendingIntent.getBroadcast(FirstScreen.this,
                    0, intent, 0);

            // We want the alarm to go off 30 seconds from now.
            Calendar calendar = Calendar.getInstance();
            calendar.setTimeInMillis(System.currentTimeMillis());
            calendar.add(Calendar.SECOND, 30);

            // Schedule the alarm!
            AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE);
            am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), sender);

The BroadCastListener You will set can call any activity in return. 您将设置的BroadCastListener可以调用任何活动作为回报。 of own app too..:) 自己的应用程序.. :)

Auto Start on any event? 自动启动任何事件? Check the IntentFilter out to make your app default for particular actions. 检出IntentFilter ,使您的应用默认执行特定操作。

Auto Start on/after a particular time? 在特定时间/之后自动启动? check Alarm out! 检查Alarm

如果要在启动时启动应用程序,请阅读本文

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM