I am currently breaking my head off, because I can start a normal startActivity()
. It is always giving me this error:
Attempt to invoke virtual method 'android.app.ActivityThread$ApplicationThread android.app.ActivityThread.getApplicationThread()' on a null object reference
I am starting it from my Application Welcome Activity:
application.getUserFromDatabase(getApplicationContext(), username, password);
Application:
public void getUserFromDatabase(Context context, String username, String password) {
//new GetFromDatabase().execute("getUser.php", "?username=" + username + "&password=" + password, this, context);
WelcomeActivity activity = new WelcomeActivity();
activity.startMainActivity();
}
AndroidManifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.mydomain.app">
<application
android:name=".MainApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
</activity>
<activity android:name=".WelcomeActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Thank you in advance :)
EDIT: I forgot adding my Method startMainActivity here:
public void startMainActivity(){
Intent startMain = new Intent(getApplicationContext(), MainActivity.class)
startActivity(startMain);
}