android 时间应用程序,android – 如何在特定时间启动应用程序

我想将此工具添加到我的应用程序中,用户可以在其中设置应用程序启动时间,然后应用程序启动.

如何在用户特定时间使用广播接收器打开我的应用程序.

我不确定这在

Android中是否可行?

如果你有什么想法请分享.

这是主要的活动代码

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

lv1=(ListView)findViewById(R.id.listView);

final ImageView splashImage = (ImageView) findViewById(R.id.imageView1);

splashImage.setBackgroundResource(R.layout.splash);

AnimationDrawable splashAnimation = (AnimationDrawable) splashImage.getBackground();

splashImage.onWindowFocusChanged(true);

splashAnimation.start();

AlarmManager am = (AlarmManager) getBaseContext().getSystemService(Context.ALARM_SERVICE);

Date futureDate = new Date(new Date().getTime() + 86400000);

Calendar cal = Calendar.getInstance();

cal.add(Calendar.MINUTE, 1);// start app in 1 min again

futureDate.setHours(0);

futureDate.setMinutes(0);

futureDate.setSeconds(20);

Intent intent = new Intent(getBaseContext(), MyAppReciever.class);

PendingIntent sender = PendingIntent.getBroadcast(getBaseContext(), 0, intent,

PendingIntent.FLAG_UPDATE_CURRENT);

am.set(AlarmManager.RTC_WAKEUP,cal.getTimeInMillis() , sender);}}

这是reciver类代码

class MyAppReciever extends BroadcastReceiver{ public void onReceive(Context context,Intent intent) {

startActivity(new Intent(context, Main_Activity.class));

}private void startActivity(Intent intent) {

// TODO Auto-generated method stub}}

我已将此行添加到清单中

现在我的广播触发器,但我得到了这个错误

10-02 17:56:27.735: E/AndroidRuntime(9020): java.lang.RuntimeException: Unable to instantiate receiver com.example.testgui.MyAppReciever: java.lang.IllegalAccessException: access to class not allowed

谢谢

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值