Hello everybody,
I'm having problems starting an activity defined inside a library. I've tried all methods I could find on the forum but none worked. So I've created a very simple activity, compiled it to a library and tried to start that activity from withing B4A, getting same problem - null pointer exception.
Library code:
I've tried to start that activity from B4A in many different ways, including a helper class in the library but nothing works, here is one of them, B4A code (the library is referenced form within B4a, and activity is defined in manifest when compiling, no errors while compiling):
Manifest code:
Error code:
I'm having problems starting an activity defined inside a library. I've tried all methods I could find on the forum but none worked. So I've created a very simple activity, compiled it to a library and tried to start that activity from withing B4A, getting same problem - null pointer exception.
Library code:
B4X:
package com.helloword;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.ActivityObject;
import anywheresoftware.b4a.BA.Author;
import anywheresoftware.b4a.BA.DependsOn;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;
import android.content.Intent;
@ActivityObject
@Author("HelloWord")
@Version(1.0f)
@ShortName("HelloWord")
public class HelloWord extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView text = new TextView(this);
text.setText("Hello World of Android! - Greetings from Java Code Geeks");
setContentView(text);
}
}
I've tried to start that activity from B4A in many different ways, including a helper class in the library but nothing works, here is one of them, B4A code (the library is referenced form within B4a, and activity is defined in manifest when compiling, no errors while compiling):
B4X:
Dim i As Intent
i.Initialize("", "")
i.SetComponent("com.helloword/.HelloWord")
StartActivity(i)
Manifest code:
B4X:
AddApplicationText(<activity android:name="com.helloword.HelloWord" />)
Error code:
B4X:
I/B4A ( 2963): ~i:** Activity (main) Create, isFirst = true **
I/B4A ( 2963): ~e:main_activity_create (java line: 244)
I/B4A ( 2963): ~e:java.lang.NullPointerException
I/B4A ( 2963): ~e: at android.content.ComponentName.<init>(ComponentName.java:75)
I/B4A ( 2963): ~e: at android.content.Intent.<init>(Intent.java:3301)
I/B4A ( 2963): ~e: at com.helloword.HelloWord$HWHelper.GetMyIntent(HelloWord.java:33)
I/B4A ( 2963): ~e: at com.glwallpaper001.main._activity_create(main.java:244)
I/B4A ( 2963): ~e: at java.lang.reflect.Method.invokeNative(Native Method)
I/B4A ( 2963): ~e: at java.lang.reflect.Method.invoke(Method.java:511)
I/B4A ( 2963): ~e: at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
I/B4A ( 2963): ~e: at com.glwallpaper001.main.afterFirstLayout(main.java:89)
I/B4A ( 2963): ~e: at com.glwallpaper001.main.access$100(main.java:16)
I/B4A ( 2963): ~e: at com.glwallpaper001.main$WaitForLayout.run(main.java:74)
I/B4A ( 2963): ~e: at android.os.Handler.handleCallback(Handler.java:615)
I/B4A ( 2963): ~e: at android.os.Handler.dispatchMessage(Handler.java:92)
I/B4A ( 2963): ~e: at android.os.Looper.loop(Looper.java:137)
I/B4A ( 2963): ~e: at android.app.ActivityThread.main(ActivityThread.java:4745)
I/B4A ( 2963): ~e: at java.lang.reflect.Method.invokeNative(Native Method)
I/B4A ( 2963): ~e: at java.lang.reflect.Method.invoke(Method.java:511)
I/B4A ( 2963): ~e: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
I/B4A ( 2963): ~e: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
I/B4A ( 2963): ~e: at dalvik.system.NativeStart.main(Native Method)
I/B4A ( 2963): ~e:java.lang.NullPointerException