Java Question Start library Activity

warwound

Expert
Licensed User
Longtime User
This has been asked before but not answered i think.

I have created an Activity (using java) and it's one class in a library.
I've added it to my manifest:

B4X:
AddApplicationText(<activity android:name="my.library.package.name.ResumeEditor"/>)

And can successfully start it from my B4A code using this method in another one of the library classes:

B4X:
public Intent GetResumeEditorIntent(){
   Intent intent=new Intent(mBA.activity, ResumeEditor.class);
   return intent;
}

In B4A i use:

B4X:
StartActivity(MyLibraryClass.GetResumeEditorIntent)

How can i create a B4A Intent (IntentWrapper) to start this Activity?

I've tried various syntax but nothing has worked:

B4X:
' all variations of the first parameter in Initialize cause No Activity found to handle Intent exceptions
Intent1.Initialize(Intent1.ACTION_VIEW, "my.library.package.name.ResumeEditor")

' and this causes an exception
' java.lang.ClassNotFoundException: my.application.package.name.resumeeditor
StartActivity("ResumeEditor")

Should i stick to creating the Intents i require using library methods or is there a way with B4A?

Martin.
 

warwound

Expert
Licensed User
Longtime User
Thanks but i still can't get it to work...

B4X:
Dim Intent1 As Intent
Intent1.Initialize("", "")
Intent1.SetComponent("my.library.package.name.ResumeEditor")

android.content.ActivityNotFoundException: No Activity found to handle Intent { act= flg=0x20000 }

B4X:
Dim Intent1 As Intent
Intent1.Initialize("", "")
Intent1.SetComponent("my.library.package.name/.ResumeEditor")

android.content.ActivityNotFoundException: Unable to find explicit activity class {my.library.package.name/my.library.package.name.ResumeEditor};
have you declared this activity in your AndroidManifest.xml?

Does the B4A compile my ResumeEditor class as resumeditor i wondered so tried all lower case too but the errors were the same.

The Activity starts ok when i use the Intent returned from my library (see first post) so i may just as well stick to that method.

Martin.
 

warwound

Expert
Licensed User
Longtime User
B4A doesn't do anything with the Activity you created inside the library. Did you add with the manifest editor?

Yep, i added it along with the PreferenceActivity:

B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="4" />
<supports-screens android:largeScreens="true" 
    android:normalScreens="true" 
    android:smallScreens="true" 
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.
AddApplicationText(<activity android:name="anywheresoftware.b4a.objects.preferenceactivity" />)
AddApplicationText(<activity android:name="my.library.package.name.ResumeEditor" />)

Martin.
 

icefairy333

Active Member
Licensed User
Longtime User
You can create any Intent you need with IntentWrapper.

B4X:
Dim i As Intent
i.Initialize("", "")
i.SetComponent("my.library.package.name/.ResumeEditor")
StartActivity(i)

the code get error
B4X:
AddApplicationText(
 <activity android:name="com.google.ads.AdActivity"
  android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
)
call with
1.
B4X:
Dim i As Intent
i.Initialize("","")
i.SetComponent("com.google.ads.AdActivity")
StartActivity(i)
2.
B4X:
Dim i As Intent
i.Initialize("","")
i.SetComponent("com.google.ads/.AdActivity")
StartActivity(i)
all of them get error not found class
 
Top