Welcome! Log In Create A New Profile

Advanced

startActivity android function giving error when compiling

Posted by Tiaan Smith 
startActivity android function giving error when compiling
May 17, 2019 11:34AM
Good Day,

I have 2 mobile applications.
- Application 1
- Application 2

What we are trying to achieve is to open an activity (mobile window) in Application 2 from Application 1 using Java code.
I made a test application in android studio and successfully achieve doing that with a few lines of code.

I am now trying to use that java code in my windev mobile application but im getting an error on compile :
- error: cannot find symbol startActivity(launchIntent);

We have tried adding all the necessary imports but still no luck.

My java code :

import android.content.ComponentName;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;


public static void BTN_Open_Application_B()
{

Intent launchIntent = new Intent();
launchIntent.setComponent(new ComponentName("com.example.myapplicationb", "com.example.myapplicationb.MyExampleActivity1"));

if (launchIntent != null) {
Toast.makeText(getApplicationContext(), " opening application b", Toast.LENGTH_SHORT).show();
startActivity(launchIntent);
} else {
Toast.makeText(getApplicationContext(), " launch Intent not available", Toast.LENGTH_SHORT).show();
}
}


Help would be greatly appreciated.

Thanks
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: