If we open android documentation we will see that Activity classes have static modifier: I’m used to declaring Activities without static modifier: What is the reason behind using static modifier in Activity class declaration? UPDATE: The static modifiers have been removed from the documentation. Answer It’s Documentation bug. Sadly, they are not rare. You’d normally only use the static modifier
Tag: android-activity
Android – Using Shared Preferences in separate class?
I want to save data using Shared Preferences in android. But I am looking to use separate class to do this task. I have implemented that class like below, But there is an error on getActivity(), How to solve this? Thanks Answer getActivity() is a method of Fragment not of your SavePref. In your case the simple fix is to
How to make app wait and then start activity or go back?
I want my activity to show a screen for 3 seconds, then go back to previous screen. But when i use But unfortunately, this does not work. This doesent show the activity waits 3 seconds and goes back. However, i want it to show its contents before going back. How can i do it ? Answer You should remove this
Android notification with RemoteViews – having activity associated with RemoteViews layout
I’ve been researching on how to create custom-layout notification using RemoteView. So far, I am able to create a notification with contentView and bigContentView pointing to a RemoteView with a custom layout xml. However, what does not happen, is to have Activity (associated with custom layout) started when this RemoteView is created. I’ve double checked and in my layout xml,
How to use interface to communicate between two activities
I am trying to make listener interface between two activities Act1 and Act2. Act1 will start Act2. If there is some event occurred in Act2, it will inform it to Act1. Problem is that I am starting new activity using Intent, so how Act1 will assign itself as listener to Act2’s interface? Act1.java Act2.java Note: Please don’t suggest me to
In Activity.onCreate(), why does Intent.getExtras() sometimes return null?
This was probably a false alarm, see my own answer. Original question below: An activity has a button that takes the user to another activity. To launch the new activity, we populate our Intent with extras, and onCreate(), the new activity reads from those extras via Intent.getExtras(). We assumed the returned bundle would be non-null, but as customer crash reports
Android Call a method from another class
I know that this Question is repeated but I can’t find the answer in the Internet. I want to call a method from another class. I have Class1 and Class2. In Class 2 I have this method: I want to call the above method from Class1. Thanks for any answer. —-EDIT—- —-LogCat— Answer You should use the following code :
How to start Activity in adapter?
I have a ListActivity with my customized adapter and inside each of the view, it may have some buttons, in which I need to implement OnClickListener. I need to implement the OnClickListener in the adapter. However, I don’t know how to call the function like startActivity() or setResult(). Since the adapter doesn’t extend to Activity. So what is the best
How to navigate from one screen to another screen
How to navigate from one Activity screen to another Activity screen? In the first screen I’m having one button if I click the button it has to move to another Activity screen. Answer