[英]How can I send a pdf created by my app to another app through URI scheme in Android?
[英]How can I install an android app that I created with another android app that I created (Android Studio)?
我的目標是有一個菜單,用戶可以在其中 select 一個新的 android 應用程序,然后將其安裝在同一部手機中。 兩個應用程序(主應用程序和新應用程序)都是由我創建的。 你能幫我嗎?
您可以下載一個 apk,然后啟動 package 管理器來安裝它。 這將詢問用戶許可,用戶可以拒絕安裝它。
可以使用這樣的東西 -
final DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
final long id = manager.enqueue(request);
BroadcastReceiver onComplete = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
Intent install = new Intent(Intent.ACTION_VIEW);
install.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
install.setDataAndType(uri,
manager.getMimeTypeForDownloadedFile(id));
startActivity(install);
unregisterReceiver(this);
finish();
}
};
registerReceiver(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
希望這可以幫助!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.