Android開發-實現第三方APP跳轉


自己創建一個按鈕:

<Button
android:id="@+id/btn_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="******"/>

實現方法:
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);
}
});

創建一個類:

//實現Application的Context引用
class ContextHolder {
static Context ApplicationContext;
public static void initial(Context context) {
ApplicationContext = context;
}
public static Context getContext() {
return ApplicationContext;
}
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM