Hi,
I want to install my app to my phone via USB or wifi (from my NAS) or sd card to my phone, tablet, or Sony Android TV, and I want my app to install a home screen icon when I press a button within the app. I am not installing the app from the Google Play store.
Can some one please provide a working *.b4a sample? The code provided here in the forum has been copy/pasted from working apps but that doesn't show/mention which libraries to use or where exactly the code goes... There is even a thread (by Woinowski) that shows how to have a button add (manually) a shortcut to the home screen, but I cannot modify the code successfully. I'm using B4A v.5. The example provided by Erel only adds a shortcut to the Application drawer but it does not add it to the home screen.
Woinowski example:
I understand from the code above that he makes a shortcut that point to different states of his database.
I only need the code to create the shortcut to my app when tapping on the button, an icon to run the app. That's all.
In cleaning his code, in the Main Activity, I get to:
But the last line: DoEventsNow is red... what does it need? What libraries, what extra "Activities"?
Also, instead of "de.woinosky.cardbaord/.main", can I type the name of my app which is "myapp.apk"? Or is it just "myapp"? Where does the "de.woinosky." come from?
In my Main Activity I have:
Then on the Designer I have a simple button called CreateShortcut.
In other words, this simple app has only one button. When you press that button it should create an app shortcut on the phone, tablet, or Android TV home screen. That's it...
Can some one please be kind and tell me what I'm missing? I mean, besides programing skills.
B4A is awesome, but at the other end is a huge lack for a great programming tutorial for those like me who have never done programming before... from a non-programming mind point of view.
Thanks in advanced.
I want to install my app to my phone via USB or wifi (from my NAS) or sd card to my phone, tablet, or Sony Android TV, and I want my app to install a home screen icon when I press a button within the app. I am not installing the app from the Google Play store.
Can some one please provide a working *.b4a sample? The code provided here in the forum has been copy/pasted from working apps but that doesn't show/mention which libraries to use or where exactly the code goes... There is even a thread (by Woinowski) that shows how to have a button add (manually) a shortcut to the home screen, but I cannot modify the code successfully. I'm using B4A v.5. The example provided by Erel only adds a shortcut to the Application drawer but it does not add it to the home screen.
Woinowski example:
B4X:
Sub CreateShortCut_Click 'I already have a button in the Designer for this Click
If CurrentState = States.EMPTY Or DataManager.CurrentDBName = Null Or DataManager.CurrentDBName = "" Then
Return
End If
Dim shortcutIntent As Intent
shortcutIntent.Initialize("", "")
shortcutIntent.SetComponent("de.woinowski.cardboard/.main")
shortcutIntent.PutExtra("CurrentDBName", DataManager.CurrentDBName)
shortcutIntent.PutExtra("CurrentDBPath", DataManager.CurrentDBPath)
shortcutIntent.PutExtra("NamedShortCut", True)
Dim in As Intent
in.Initialize("", "")
in.PutExtra("android.intent.extra.shortcut.INTENT", shortcutIntent)
in.PutExtra("android.intent.extra.shortcut.NAME", DataManager.RemoveSuffix(DataManager.CurrentDBName))
If GetApi > 10 Then
in.PutExtra("android.intent.extra.shortcut.ICON", LoadBitmap(File.DirAssets, "CardBoardMini.png"))
Else
in.PutExtra("android.intent.extra.shortcut.ICON", LoadBitmap(File.DirAssets, "CardBoardMicro.png"))
End If
in.Action = "com.android.launcher.action.INSTALL_SHORTCUT"
Dim p As Phone
p.SendBroadcastIntent(in)
DoEventsNow
End Sub
I understand from the code above that he makes a shortcut that point to different states of his database.
I only need the code to create the shortcut to my app when tapping on the button, an icon to run the app. That's all.
In cleaning his code, in the Main Activity, I get to:
B4X:
Sub CreateShortCut_Click 'I already have a button in the Designer for this Click
Dim shortcutIntent As Intent
shortcutIntent.Initialize("", "")
shortcutIntent.SetComponent("de.woinowski.cardboard/.main") '<---- can I type myapp.apk/main here? I don't get this part.
shortcutIntent.PutExtra("NamedShortCut", True)
Dim in As Intent
in.Initialize("", "")
in.PutExtra("android.intent.extra.shortcut.INTENT", shortcutIntent)
in.PutExtra("android.intent.extra.shortcut.ICON", LoadBitmap(File.DirAssets, "mypic.gif"))
in.Action = "com.android.launcher.action.INSTALL_SHORTCUT"
Dim p As Phone
p.SendBroadcastIntent(in)
DoEventsNow '<------------this is red and is missing something???
End Sub
But the last line: DoEventsNow is red... what does it need? What libraries, what extra "Activities"?
Also, instead of "de.woinosky.cardbaord/.main", can I type the name of my app which is "myapp.apk"? Or is it just "myapp"? Where does the "de.woinosky." come from?
In my Main Activity I have:
B4X:
Sub Globals
Private CreateShortcut As Button
End Sub
Then on the Designer I have a simple button called CreateShortcut.
In other words, this simple app has only one button. When you press that button it should create an app shortcut on the phone, tablet, or Android TV home screen. That's it...
Can some one please be kind and tell me what I'm missing? I mean, besides programing skills.
B4A is awesome, but at the other end is a huge lack for a great programming tutorial for those like me who have never done programming before... from a non-programming mind point of view.
Thanks in advanced.
Last edited: