This solution works for old default projects (activity). But B4XPage projects cause the error mentioned in post #3. Any guru can make it work for B4XPage projects?
Here is B4A code Note: It does not work in android emulator
B4X:
Sub Button1_Click
Dim jo As JavaObject
jo.InitializeContext
jo.RunMethod("openCalculator", Null)
End Sub
#If JAVA
import android.content.Intent;
public void openCalculator() {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_APP_CALCULATOR);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
#End If
I got the "cannot find symbol startActivity(intent);
" error while compiling the above code. Could someone tell me what went wrong, please? Test app attached.
I got the "cannot find symbol startActivity(intent);
" error while compiling the above code. Could someone tell me what went wrong, please? Test app attached.
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private xui As XUI
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
Dim jo As JavaObject
jo.InitializeContext
jo.RunMethod("openCalculator", Null)
End Sub
#If JAVA
import android.content.Intent;
public void openCalculator() {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_APP_CALCULATOR);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
#End If
Private Sub Button2_Click
Dim Pm As PackageManager 'Phone library
Dim Inte As Intent
For Each st As String In Pm.GetInstalledPackages
If st.Contains("calc") =True Then
Inte=Pm.GetApplicationIntent(st)
If Inte.IsInitialized Then StartActivity(Inte)
Exit
End If
Next
End Sub
The problem associated with this approach is that Google considers the required permission QUERY_ALL_PACKAGES dangerous and wouldn't allow an app to have it normally.
The problem associated with this approach is that Google considers the required permission QUERY_ALL_PACKAGES dangerous and wouldn't allow an app to have it normally.
Here is B4A code Note: It does not work in android emulator
B4X:
Sub Button1_Click
Dim jo As JavaObject
jo.InitializeContext
jo.RunMethod("openCalculator", Null)
End Sub
#If JAVA
import android.content.Intent;
public void openCalculator() {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_APP_CALCULATOR);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
#End If
This solution works for old default projects (activity). But B4XPage projects cause the error mentioned in post #3. Any guru can make it work for B4XPage projects?
My project failed because it's B4XPage project while yours work because it's an activity based project. Now I'm wondering how to make it work with B4Xpage projects
This solution works for old default projects (activity). But B4XPage projects cause the error mentioned in post #3. Any guru can make it work for B4XPage projects?