Android开发-实现第三方APP跳转
生活随笔
收集整理的這篇文章主要介紹了
Android开发-实现第三方APP跳转
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
自己創(chuàng)建一個按鈕:
<Buttonandroid:id="@+id/btn_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="******"/>
實現(xiàn)方法: btn_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
PackageManager packageManager = ContextHolder.getContext().getPackageManager();
Intent intent = packageManager.getLaunchIntentForPackage("******"); //“******”里面填寫項目的包名
ContextHolder.getContext().startActivity(intent);
}
});
創(chuàng)建一個類:
//實現(xiàn)Application的Context引用 class ContextHolder {
static Context ApplicationContext;
public static void initial(Context context) {
ApplicationContext = context;
}
public static Context getContext() {
return ApplicationContext;
}
}
轉(zhuǎn)載于:https://www.cnblogs.com/yunting/p/11007898.html
總結(jié)
以上是生活随笔為你收集整理的Android开发-实现第三方APP跳转的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [c++]C++关键字之friend
- 下一篇: 最新鲜最详细的Android SDK下载