Call other APK Intent

mdp

Member
Licensed User
Longtime User
hello
sorry for the dumb question, but im new n using intent :|
how to use other APK intent and get the result from the intent? :confused:
I know the intent, the parameter, and the expected output.
what i'm to achieve is i'd like to start other APK intent, wait it until it's done doing the job, get the result and use it in my B4A program. Can i do that?
any example is welcome
thanks in advance
 

mdp

Member
Licensed User
Longtime User
yes one of my team mate wrote it
what must i do sir to call his APK and get the result?
the APK is an OCR APK which he wrote using Tesseract and java android.
thanks
 
Upvote 0

mdp

Member
Licensed User
Longtime User
If you do not want to write a library then you can ask the other developer to send an intent and call your activity (you can send the package name and activity name as part of the intent).
how to do it sir?
simple example please if possible
 
Upvote 0

mdp

Member
Licensed User
Longtime User
do his app run first and then call my app activity and send the result or my app do the call? i'm bit confused :(
i'd like my app that do the call and wait for the result from his app
 
Upvote 0

mdp

Member
Licensed User
Longtime User
ok, the other guy has send me the intent information, but after i initialize it using code below i get error : No activity handle this intent? any hint? thank you
name intent from his apk : edu.sfsu.cs.orange.ocr.CaptureActivity
my code :

Dim intent1 As Intent
intent1.Initialize("edu.sfsu.cs.orange.ocr.CaptureActivity","")
StartActivity(intent1)
 
Upvote 0

mdp

Member
Licensed User
Longtime User
ok, after some package debugging finally can start the intent correctly
now how to get the data?
he note that the data can be retrieve from his intent is with name QRCodeData and OCRData.
 
Upvote 0

mdp

Member
Licensed User
Longtime User
this is my b4a code :
B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.

End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.

   Dim Button1 As Button
   Dim Label1 As Label   
   Dim intent1 As Intent
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("lytMain")
End Sub

Sub Activity_Resume
   If   intent1.IsInitialized Then   'is it correct???
      intent1 = Activity.GetStartingIntent
      ToastMessageShow("extra name : " & intent1.ExtrasToString,True)   'how to get the data???
   End If
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click   
   intent1.Initialize(intent1.ACTION_MAIN,"")
   intent1.SetComponent("edu.sfsu.cs.orange.ocr/.CaptureActivity")
   StartActivity(intent1)   'ocr apk run 
End Sub
 
Last edited:
Upvote 0

mdp

Member
Licensed User
Longtime User
ok, got the data readed
finally :sign0188:
just 1 question :
when i call an intent and the intent call my package and activity back, did my all previous variabel empty(back to its origininal state)?
 
Upvote 0

raytronixsystems

Active Member
Licensed User
Longtime User
Why not have your app start the second app and periodically check for resultant data from the second app by means of a file written by the second app. This could be done with a timer at any interval that would not slow down the system. As long as there is no file then there is no result from the peer app. When the file is written by the peer app and detected by the first app then the resultant data can be read from the second app. Very simple and foolproof. You can even test the logic yourself without the second app by creating a dummy file. Any amount of data can be transferred via the file in whatever format that you and your friend set up in advance, There are numerous examples of file manipulation up here for you to study and use in your app. Of course this is not as elegant as the other solutions submitted by my peers but it will do the job for you.

Regards,
Ray
 
Last edited:
Upvote 0

mdp

Member
Licensed User
Longtime User
ok, got all wrap up
thank you all
time for a relax a while.... :sign0098::icon_clap::sign0060:
 
Upvote 0
Top