Is it possible to create implicit intent to call our own activity? If possible is it useful or better option is Explicit Intent?
please explain your situation more...
If a single Activity is there and you want to call the same activity again from this to have any refresh sort of thing...
Then its not a good idea...
All the views can be updated without calling the same activity again.
And if new view is to be generated then use another activity
Related
I'm just curious to find if there is any difference for starting activity between these two types
StartActivity (typeof (MainActivity));
StartActivity (new Intent (this,typeof (MainActivity)));
Consider the first as a shortcut for the second.
If you dont want to share any data to the new activity you can call the first.
In other cases you may want to pass an Id or any other data to use in the target activity through a Bundle with the PutExtra methods of the Intent.
In my application I want send data from activity to another activity and for this I don't want use Intent.
I know I can use this code :
Intent intent = new Intent(context, Activity.class);
intent.putExtra("name", value);
startActivity(intent);
and for this I don't want use SharedPreferences again!
Do you know other way for send data from activity to another activity without 2 above ways?
If I understand correctly, you are looking for a way to pass data from one Activity to another Activity without using either SharedPreferences or the SQLite database. Using an Intent is OK but not with startActivity(). I assume that this also goes for startActivityForResult().
Two Activitys of the same application will as a rule not be in the foreground at the same time, so LocalBroadcastManager won't be very helpful in this case. Simply "sending" won't be possible, one needs some kind of middle man.
You could look into EventBus libraries, e.g. Otto EventBus
But maybe you'd prefer to work with some type of POJO to hold the data, and perhaps some Observer which the Activitys could query. Such a class could be implemented as a field in a custom class extending Application.
Can i call second activity from current activity without use intent? and why use intent, why not call second activity direct from the first activity?.
What does intent do in android?
Because to start any new Activity Android must have to go through the life cycle of an Activity. So it is necessary to use intent.
http://developer.android.com/reference/android/content/Intent.html
you can't ,see this link android is designed in this way to launch another activity
Intent says to Android you need open a new activity. Always when you need open a new Activity, you need "alert" the S.O before. Because of this we use Intent.
Activities doesn't work like a simple class, when we just instantiate.
This link will help you
http://www.vogella.com/tutorials/AndroidIntent/article.html
I want to pass the WebView from One activity to another Activity.
how to do that. I referred How do I pass an object from one activity to another on Android?
but still not getting any idea for this. Please help me to get this....
Sounds to me like you may want a broadcast receiever...
try looking here: BroadcastReceiver
That will let one activity send a message to another
either u try to use finish() an the passed Activity or you simply call finish() in the activity after it's done with it's calculations
Are you sure you want that in an Android activity, not just a normal Java class?
I want to call onCreate(Bundle cicici); from other class then i am getting "NullPointerException", so please guide me how can i call the onCreate() from another class.
There is only one way in which onCreate can be called, by starting an Activity, since onCreate is as part of Activity life cycle.
startActivity(new Intent(presentActivity.this, NextActivity.class));
if you want to call onCreate in order to actually present a new screen, then you need to create a the new Activity using the android framework style.
Ingredients:
1- An event to call your new activity( ie. onClickListener of a Button or list triggered)
2- On the event you need to create an Intent with the reference of the current activity and a class reference of your new Activity, example:
Intent intent =new Intent(CurrenActivity.this, MyNewActivity.class);
3- You need to call this activity depending on what you'll need you use startActivity or startActivityForResult, the last is use when you expect a response from your activity.
You can also refer to Android documentation Common Task, let us know if its helpful
It depends what you want to do in the second activity. If you want to create a simple task you can always use dialogs and you can show them inside your activity.
Or, on a second thought, you can hide some of your views and enable others but I guess that's not an orthodox solution :)