A alvinmb Member Licensed User Longtime User Jun 12, 2012 #1 How would you go about launching an external application from a button in a Basic4android application, and return to your B4a app when you close the app that you just launched?
How would you go about launching an external application from a button in a Basic4android application, and return to your B4a app when you close the app that you just launched?
Kevin Well-Known Member Licensed User Longtime User Jun 13, 2012 #2 Replace com.package.tolaunch with the package name of the app you want to launch. If the user exits (backs out of) the launched app, Android will automatically return to your app afterwards. Code: Sub YourButton_Click Try Dim Intent1 As Intent Dim pm as PackageManager Intent1 = pm.GetApplicationIntent ("com.package.tolaunch") StartActivity (Intent1) Catch ToastMessageShow ("Failed to launch app! Is it installed?", True) End Try End Sub Upvote 0
Replace com.package.tolaunch with the package name of the app you want to launch. If the user exits (backs out of) the launched app, Android will automatically return to your app afterwards. Code: Sub YourButton_Click Try Dim Intent1 As Intent Dim pm as PackageManager Intent1 = pm.GetApplicationIntent ("com.package.tolaunch") StartActivity (Intent1) Catch ToastMessageShow ("Failed to launch app! Is it installed?", True) End Try End Sub
A AntAnt Member Licensed User Longtime User Aug 19, 2013 #4 Hi there, is the package enough to launch the application? I mean: don't you need to also specify apk file name? Thanks in advance A. Upvote 0
Hi there, is the package enough to launch the application? I mean: don't you need to also specify apk file name? Thanks in advance A.
A AntAnt Member Licensed User Longtime User Aug 19, 2013 #6 NJDude said: No. Click to expand... Eheh great! Thank you very much. I tested it with my app and it works. Now, one (hopefully last) question. I have to add some "string+relative command" to the intent. With java/android would use Intent.putExtra (String name, String value) Now I'm looking at b4a intent instance and it gives a method putExtra but it has these expected parameters: Intent.putExtra(String name, Value Obj). For instance, having to pass to the putExtra: "max_number"], 2 how is it suppose to do it, as it doesnt accept an int type as second parameter? Thanks again A. Upvote 0
NJDude said: No. Click to expand... Eheh great! Thank you very much. I tested it with my app and it works. Now, one (hopefully last) question. I have to add some "string+relative command" to the intent. With java/android would use Intent.putExtra (String name, String value) Now I'm looking at b4a intent instance and it gives a method putExtra but it has these expected parameters: Intent.putExtra(String name, Value Obj). For instance, having to pass to the putExtra: "max_number"], 2 how is it suppose to do it, as it doesnt accept an int type as second parameter? Thanks again A.
A AntAnt Member Licensed User Longtime User Aug 19, 2013 #7 ah of course the same issue with boolean types as second parameters (or strings..or any other type not object) Upvote 0
ah of course the same issue with boolean types as second parameters (or strings..or any other type not object)
NJDude Expert Licensed User Longtime User Aug 20, 2013 #8 In B4A, the second parameter in PutExtra is an OBJECT, not a string Code: myIntent.PutExtra(Name As String, Value As Object) You could do something like: Code: myIntent.PutExtra("max_number", "2") Last edited: Aug 20, 2013 Upvote 0
In B4A, the second parameter in PutExtra is an OBJECT, not a string Code: myIntent.PutExtra(Name As String, Value As Object) You could do something like: Code: myIntent.PutExtra("max_number", "2")
J Juan Pedro Arce Member Licensed User Longtime User Sep 22, 2014 #9 Ok, great, the answer shows the solution, but how can one get the name of the app in the Is there a way to obtain the name of the application in the form of "com.package.tolaunch" for a specific app? For example I am trying to call "MDScan Lite" (Document Scan into PDF). Is there a way to get the name in the package notation? Upvote 0
Ok, great, the answer shows the solution, but how can one get the name of the app in the Is there a way to obtain the name of the application in the form of "com.package.tolaunch" for a specific app? For example I am trying to call "MDScan Lite" (Document Scan into PDF). Is there a way to get the name in the package notation?
Erel B4X founder Staff member Licensed User Longtime User Sep 22, 2014 #10 PackageManager.GetApplicationLabel returns the name of the app. Upvote 0
JOTHA Well-Known Member Licensed User Longtime User Nov 8, 2015 #11 Hi friends, just 2 questions: 1) is it possible to "click" on a button in the external app by Intent? 2) does Code: Intent1.PutExtra("EditText_01", "XYZ") putting the Text "XYZ" into the field? Thank you for your help. Upvote 0
Hi friends, just 2 questions: 1) is it possible to "click" on a button in the external app by Intent? 2) does Code: Intent1.PutExtra("EditText_01", "XYZ") putting the Text "XYZ" into the field? Thank you for your help.
DonManfred Expert Licensed User Longtime User Nov 8, 2015 #12 1) NO 2) yes, if the receiving app supports such "extra". But usually NO Upvote 0
JOTHA Well-Known Member Licensed User Longtime User Nov 8, 2015 #13 @DonManfred: Thank you for your response. My problem is ... I have two own apps. In the first app is a number generated. I want to click a button and open the other app. That works fine. But then I want to click automatically into the other app to get onto a panel and then I want automatically copy the number from the first app into a TextEdit in the other app. Is there any idea? Upvote 0
@DonManfred: Thank you for your response. My problem is ... I have two own apps. In the first app is a number generated. I want to click a button and open the other app. That works fine. But then I want to click automatically into the other app to get onto a panel and then I want automatically copy the number from the first app into a TextEdit in the other app. Is there any idea?
DonManfred Expert Licensed User Longtime User Nov 8, 2015 #14 JOTHA said: Is there any idea? Click to expand... If the second app is YOUR app then you have the chance to change it. Start your second app with an intent giving some EXTRAs and in app 2 you expect to get parameter in the extras. You read them and use them like you wish... See here for more details. Maybe this can also be of help. Upvote 0
JOTHA said: Is there any idea? Click to expand... If the second app is YOUR app then you have the chance to change it. Start your second app with an intent giving some EXTRAs and in app 2 you expect to get parameter in the extras. You read them and use them like you wish... See here for more details. Maybe this can also be of help.
JOTHA Well-Known Member Licensed User Longtime User Nov 9, 2015 #15 Hello DonManfred, thank you for the links above. I've read the first one, but it was too much for the first time ... I searched for a "fast-and-easy-solution". But now it seems that I have to read and learn with more time ... Thanks! Upvote 0
Hello DonManfred, thank you for the links above. I've read the first one, but it was too much for the first time ... I searched for a "fast-and-easy-solution". But now it seems that I have to read and learn with more time ... Thanks!