自动启动支付宝支付宝小插件

来源:互联网 发布:js object 增加属性 编辑:程序博客网 时间:2024/05/01 07:33
/***如果想要自动启动一个软件需要加入摸个权限*/<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>原理:接受到系统发出的开机完成广播,我们设置与此广播相同的Action即可接受此信息如下:        <receiver android:name="BootCompleteBroadCast">            <intent-filter >                <action android:name="android.intent.action.BOOT_COMPLETED"/>                <category android:name="android.intent.category.HOME" />            </intent-filter>        </receiver>接下来我们就要完成接收器的具体实现如何打开支付宝,上个文章已经有所实现,现在直接上代码。public class BootCompleteBroadCast extends BroadcastReceiver{    @Override    public void onReceive(Context arg0, Intent arg1) {        // TODO Auto-generated method stub        Intent intent = arg0.getPackageManager().getLaunchIntentForPackage("com.eg.android.AlipayGphone");        if( intent != null ){            arg0.startActivity( intent );        }else{            Toast.makeText( arg0 , "尚未安装支付宝!", Toast.LENGTH_SHORT ).show();        }    }}完毕
0 0
原创粉丝点击