Run app with parameter

henry1311

Member
Licensed User
Longtime User
ENGLISH
Greetings to all
I would need to run an app by sending one or more parameters.
In the home I need to position 3 icons that are running the same application, each sends a parameter (or even 2, 3 or none!)
By controlling the parameter I can activate a specific activity.

example:
icona_1: nomeapp.apk with no parameters (normal application)
icona_2: nomeapp.apk with parameter 1 (i run directly the activity '1')
icona_3: nomeapp.apk with parameter 2 (i run directly the activity '2')
or
icona_4: nomeapp.apk with parameter 1, "basic4", "Android" (I run directly to the activity '1' with fields (field1 and field2) default to' basic4 'and' Android ')

All this to avoid installing 3 applications which do basically the same thing, using the same database, but that does not need to start making selections from menus or buttons.

If all this were possible, as you 'install' the additional icons?

Hello
thanks
Enrico

-----

ITALIANO
Un saluto a tutti
Io avrei la necessità di eseguire una app inviando uno o più parametri.
Nella home avrei la ncessità di posizione 3 icone che eseguono la stessa applicazione, ciascuna invia un parametri (o anche 2, 3 o nessuno!)
Controllando il paraamtro posso attivare una activity specifica.

Esempio :
icona_1 : nomeapp.apk con nessun parametro (normale applicazione)
icona_2 : nomeapp.apk con parametro 1 (eseguo direttamente l'activity '1')
icona_3 : nomeapp.apk con parametro 2 (eseguo direttamente l'activity '2')

oppure
icona_4 : nomeapp.apk con parametro 1, "basic4", "android" (eseguo direttamente l'activity '1' con campi preimpostati a 'basic4' e 'android')

Tutto questo per evitare di installare 3 applicazioni che fanno sostanzialmente la stessa cosa, utilizzano lo stesso database, ma che all'avvio non sia necessario effettuare selezioni da menu o da bottoni.

Se tutto ciò fosse fattibile, come si 'installano' le icone aggiuntive?

Ciao
Grazie
Enrico
 

mc73

Well-Known Member
Licensed User
Longtime User
Why not adding a simple form containing the different actions you wish to perform?
Even an inputList would do the trick.
 
Upvote 0

henry1311

Member
Licensed User
Longtime User
ENGLISH
Thanks for the reply.
I do not know if I understand the answer!

Now the application works like this:
- I run the app
- Opening activity_menu with 4 buttons:
- Btn1 performs activity_1
- Btn2 performs activity_2
- Btn3 performs activity_3
* - In this activity you need the input of 2 fields: Field_1 and Field_2 (enhancement must be different for each smartphone, the farm will have 5 right now!)
- Btnesce: exit the app

My client would NOT go for activity_menu, but direct access commissioning activity_1 icon on the home of your smartphone!

If I do not find other ways, will install 3 applications: each of them with the appropriate activity.
Each application will have a variable switch ... but it is not a good thing!

Hello
Enrico
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Question: are these activities related to each other? Or, perhaps we're talking about different apps?
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
Sounds to me as if you want to start an Activity with an Intent and that Intent contains the data that you want to pass to the new Activity.

Basic4android - Core

You can create an Intent and use PutExtra to add data to that Intent.

In the Activity that the Intent starts you can use GetStartingIntent to get the Intent that started that Activity.

The StartingIntent GetExtra method will give you the data that you want to pass to the new Activity.

Martin.
 
Upvote 0

henry1311

Member
Licensed User
Longtime User
THANKS...

Enclosed is a sample project ... 10 lines in all!

in Process_globals I put the variable that should be the parameters received from the home of the smartphone / tablet.


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.


' these are the parameters that should be received from outside
Dim param1 As Int
Dim param2, param3 As String
param1=0
param2="txtxtx1"
param3="txtxtx2"


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 Button2 As Button
   Dim Button3 As Button
   Dim Button4 As Button

End Sub

Sub Activity_Create(FirstTime As Boolean)

   If param1=0 Then
      Activity.LoadLayout("amain0")
   End If
   If param1=1 Then
      StartActivity(actmain1)
   End If
   If param1=2 Then
      StartActivity(actmain2)
   End If
   If param1=3 Then
      StartActivity(actmain3)
   End If

End Sub

Sub Activity_Resume
   'Here we start listening for SensorChanged events.
   'By checking the return value we knoe if the sensor is supported.

   If param1>0 Then
      Activity.Finish
   End If

End Sub

Sub Activity_Pause (UserClosed As Boolean)
   'Stop listening for events.

End Sub

Sub Button1_Click
   StartActivity(actmain1)
End Sub

Sub Button2_Click
   StartActivity(actmain2)
End Sub

Sub Button3_Click
   StartActivity(actmain3)
End Sub

Sub Button4_Click
   Activity.Finish   
End Sub


in VisualFoxPro (similar VisualBasic!) :
do p15
or p15 do with 0, "", ""

do p15 do with 1, "", ""
do p15 with p15 2, "", ""
p15 do with 3, "txtxtx1", "txtxtx2"

From the attached picture:
If I click on P15 = no parameters
If I click on p15_1 = send parameters 1 and empty string1 and string2
If I click on P15_2 = send parameters 2 and string1 and string2 empty
If I click on p15_3 = send parameters 3 and string "txtxtx1" and string "txtxtx2"

Question:
If this were possible, how can I install with the application icons p15_1, P15_2, p15_3 so they send their parameters?

The link/icon P15 is automatically created from install process.

Thanks again and sorry if I was not clear.
Ciao
Enrico
 

Attachments

  • p15.zip
    11 KB · Views: 322
  • screen_03.png
    screen_03.png
    32 KB · Views: 385
Upvote 0
Top