Best way to add Activity to an Android project in Eclipse?
When adding an activity to an existing Android project, I manually create a new class – is that the best / preferred way? How do others handle that? 8 Answers 8
When adding an activity to an existing Android project, I manually create a new class – is that the best / preferred way? How do others handle that? 8 Answers 8
Is there a native android way to get a reference to the currently running Activity from a service? I have a service running on the background, and I would like to update my current Activity when an event occurs (in the service). Is there a easy way to do that (like the one I suggested … Read more
In my Android application, I have two activity classes. I have a button on the first one and I want to show the second when it is clicked, but I get an error. Here are the classes: public class FirstActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button orderButton = (Button)findViewById(R.id.order); … Read more
How can I define the transition between two activities for Android 1.5 and later? I would like an activity to fade in. 14 Answers 14
In developer console error reports sometimes I see reports with NPE issue. I do not understand what is wrong with my code. On emulator and my device application works good without forcecloses, however some users get NullPointerException in fragment class when the getActivity() method is called. Activity pulic class MyActivity extends FragmentActivity{ private ViewPager pager; … Read more
Whenever my broadcast is executed I want to show alert to foreground activity. 17 Answers 17
This one has me stumped. I need to call an activity method from within a custom layout class. The problem with this is that I don’t know how to access the activity from within the layout. ProfileView public class ProfileView extends LinearLayout { TextView profileTitleTextView; ImageView profileScreenImageButton; boolean isEmpty; ProfileData data; String name; public ProfileView(Context … Read more
I’ve 2 activities, Activity1 and Activity2. In Activity1 I’ve a Button and TextView. When the button is clicked Activity2 is started. In Activity2 I’ve an EditText. I want to display the data retrieved from EditText in Activity2 in the TextView in Activity1 when back is pressed from Activity2. can someone help me with the code … Read more
I have a fragment (F1) with a public method like this public void asd() { if (getActivity() == null) { Log.d(“yes”,”it is null”); } } and yes when I call it (from the Activity), it is null… FragmentTransaction transaction1 = getSupportFragmentManager().beginTransaction(); F1 f1 = new F1(); transaction1.replace(R.id.upperPart, f1); transaction1.commit(); f1.asd(); It must be something that … Read more
I have an Activity with 3 EditTexts and a custom view which acts a specialised keyboard to add information into the EditTexts. Currently I’m passing the Activity into the view so that I can get the currently focused edit text and update the contents from the custom keyboard. Is there a way of referencing the … Read more