Vinians2006 Active Member Licensed User Longtime User Mar 23, 2012 #1 I want to create a button on my app where the user click and the app download the apk and tell the android to install it. How can I do it ? I know how to download but how can I tell the android to install it with my own app being running ?
I want to create a button on my app where the user click and the app download the apk and tell the android to install it. How can I do it ? I know how to download but how can I tell the android to install it with my own app being running ?
NJDude Expert Licensed User Longtime User Mar 23, 2012 #2 After downloading the file you could install it like this: Code: Copy Dim iIntent As Intent iIntent.Initialize(iIntent.ACTION_VIEW, "file:///sdcard/MyAPK.apk") iIntent.SetType("application/vnd.android.package-archive") StartActivity(iIntent) Upvote 0
After downloading the file you could install it like this: Code: Copy Dim iIntent As Intent iIntent.Initialize(iIntent.ACTION_VIEW, "file:///sdcard/MyAPK.apk") iIntent.SetType("application/vnd.android.package-archive") StartActivity(iIntent)
Vinians2006 Active Member Licensed User Longtime User Mar 23, 2012 #3 Nice! But the download method on FTP dont require a URI, how can I convert an absolute FTP local path to a URI ? Im download things on the path File.DirInternal how can I access File.DirInternal using a URI format ? See the download code: Code: Copy mFTP.DownloadFile("App.apk", _ True, _ File.DirInternal, _ "App.apk") Thanks Last edited: Mar 23, 2012 Upvote 0
Nice! But the download method on FTP dont require a URI, how can I convert an absolute FTP local path to a URI ? Im download things on the path File.DirInternal how can I access File.DirInternal using a URI format ? See the download code: Code: Copy mFTP.DownloadFile("App.apk", _ True, _ File.DirInternal, _ "App.apk") Thanks
NJDude Expert Licensed User Longtime User Mar 23, 2012 #4 You just need the location of the downloaded file: Code: Copy TheFile = File.DirInternal & "/MyApk.apk" iIntent.Initialize(iIntent.ACTION_VIEW, "file:///" & TheFile) ... You download first, finished downloading, then install. Last edited: Mar 23, 2012 Upvote 0
You just need the location of the downloaded file: Code: Copy TheFile = File.DirInternal & "/MyApk.apk" iIntent.Initialize(iIntent.ACTION_VIEW, "file:///" & TheFile) ... You download first, finished downloading, then install.
Vinians2006 Active Member Licensed User Longtime User Mar 23, 2012 #5 Ok, I downloaded the file and verified that the file was there. But Im getting this BIG error see: main_ftp_downloadcompleted (java line: 329) android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=/data/data/com.netsoft.nsmobile/files/NSMobile.apk typ=application/vnd.android.package-archive flg=0x20000 } at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378) at android.app.Activity.startActivityForResult(Activity.java:2836) at android.app.Activity.startActivity(Activity.java:2942) at anywheresoftware.b4a.keywords.Common.StartActivity(Common.java:665) at com.netsoft.nsmobile.main._ftp_downloadcompleted(main.java:329) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:113) at anywheresoftware.b4a.BA$1.run(BA.java:218) at android.os.Handler.handleCallback(Handler.java:587) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:143) at android.app.ActivityThread.main(ActivityThread.java:4717) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) at dalvik.system.NativeStart.main(Native Method) android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=/data/data/com.netsoft.nsmobile/files/NSMobile.apk typ=application/vnd.android.package-archive flg=0x20000 } Installing file. PackageAdded: package:com.netsoft.nsmobile ** Activity (main) Create, isFirst = true ** ** Activity (main) Resume ** Click to expand... Oh my gosh..... Im sorry for a lot of question but I really need this. My app is done and I need this working. Thanks a lot for trying to help me. Upvote 0
Ok, I downloaded the file and verified that the file was there. But Im getting this BIG error see: main_ftp_downloadcompleted (java line: 329) android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=/data/data/com.netsoft.nsmobile/files/NSMobile.apk typ=application/vnd.android.package-archive flg=0x20000 } at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378) at android.app.Activity.startActivityForResult(Activity.java:2836) at android.app.Activity.startActivity(Activity.java:2942) at anywheresoftware.b4a.keywords.Common.StartActivity(Common.java:665) at com.netsoft.nsmobile.main._ftp_downloadcompleted(main.java:329) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:113) at anywheresoftware.b4a.BA$1.run(BA.java:218) at android.os.Handler.handleCallback(Handler.java:587) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:143) at android.app.ActivityThread.main(ActivityThread.java:4717) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) at dalvik.system.NativeStart.main(Native Method) android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=/data/data/com.netsoft.nsmobile/files/NSMobile.apk typ=application/vnd.android.package-archive flg=0x20000 } Installing file. PackageAdded: package:com.netsoft.nsmobile ** Activity (main) Create, isFirst = true ** ** Activity (main) Resume ** Click to expand... Oh my gosh..... Im sorry for a lot of question but I really need this. My app is done and I need this working. Thanks a lot for trying to help me.
NJDude Expert Licensed User Longtime User Mar 23, 2012 #6 Oops!, I made a boo-boo, I have corrected the example, it should work now. Upvote 0
Vinians2006 Active Member Licensed User Longtime User Mar 23, 2012 #7 Thanks a lot. Its seems that worked 50%, now Im getting this message "Há um problema com a anaslise do pacote" in english "There's a problem analising the package". Its because its a not signed apk ? Upvote 0
Thanks a lot. Its seems that worked 50%, now Im getting this message "Há um problema com a anaslise do pacote" in english "There's a problem analising the package". Its because its a not signed apk ?
NJDude Expert Licensed User Longtime User Mar 23, 2012 #8 What do you mean by signed?, hey, if you want, go to the chat room it will be faster. Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Mar 24, 2012 #9 It is not related to the signing key. The file must be located in the storage card. The installer cannot access files stored in the internal folder. Upvote 0
It is not related to the signing key. The file must be located in the storage card. The installer cannot access files stored in the internal folder.