当前位置:   article > 正文

android 9.0 activity与service启动_android 第三方服务action

android 第三方服务action

android 9.0 启动activity
方法一:
Intent intent = new Intent();
intent.setAction(“xx.xx.xx”);
intent.putExtra(“qwert”,1); //可以省略
intent.setComponent(new ComponentName(“包名”,“绝对路径”));
mContext.startActivity(intent);

方法二:
PackageManager m = mContext.getPackageManager();
Intent i = m.getLaunchIntentForPackage(“包名”);
i.putExtra(“qwert”,1); //可以省略
if(null != i){
mContext.startActivity(i);
}

android 9.0 启动service






Intent intent = new Intent(“包名.XxxService”);
intent.setPackage(getPackageName());
startService(intent);






String action = “qqqqqqq”;
Intent i = new Intent();
i.setAction(action);
i.setComponent(new ComponentName(“service所在包”, “service绝对路径”));
bindService(i, mConnect, Context.BIND_AUTO_CREATE);

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/273086
推荐阅读
相关标签
  

闽ICP备14008679号