i'm new in Android developing.
I've to start a new Activity. Commonly, i would write the following code:
Intent i = new Intent(Activity1.this, Activity2.class);
Activity1.this.startActivity(i);
but now i need to start a new activity from an instance of that activity (because i don't want to start a generic activity of that type, i need to call his constructor to define his attributes). Something like this:
Activity2 instance = new Activity2(parameters);
Intent i = new Intent(Activity1.this, instance);
Activity1.this.startActivity(i);
Is it possible?
FLAG_ACTIVITY_SINGLE_TOP | Intent. FLAG_ACTIVITY_CLEAR_TOP | Intent. FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(storeIntent); It will call onCreate() only once on first launch of activity, if activity is already running it calls only onNewIntent() instead of create new instance of activity or calling onCreate.
In Android Studio 2, just right click on app and select New > Activity > ... to create desired activity type. Save this answer.
If both application have the same signature (meaning that both APPS are yours and signed with the same key), you can call your other app activity as follows: Intent LaunchIntent = getActivity(). getPackageManager(). getLaunchIntentForPackage(CALC_PACKAGE_NAME); startActivity(LaunchIntent);
I think you're better off to add a bundle to your intent, and read the info out that. You pass your parameters with that bundle.
example:
Intent myIntent = new Intent(this, BlipImageSender.class);
Bundle paramets = new Bundle();
paramets.putString("YOUR_PARAM_IDENT","your_parameter_value");
myIntent.putExtras(paramets);
this.startActivity(myIntent);
and in your class:
String your_param_value = getIntent().getExtras().getString("YOUR_PARAM_IDENT");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With