Tag: android-activity

Reload activity in Android

Is it a good practice to reload an Activity in Android? What would be the best way to do it? this.finish and then this.startActivity with the activity Intent?

switching activities without animation

How can I use properly the Intent flag FLAG_ACTIVITY_NO_ANIMATION in AndroidManifest file? I supose my problem is trivial, but I can’t find good example or solution to it. <intent-filter> <data android:name=”android.content.Intent.FLAG_ACTIVITY_NO_ANIMATION” /> </intent-filter> However no error is reported by compliator, but data isn’t correct. I just want to disable animation in case switching between activities. […]

How can I return to a parent activity correctly?

I have 2 activities (A and B) in my android application and I use an intent to get from activity A to activity B. The use of parent_activity is enabled: <activity android:name=”.B” android:label=”B” > <meta-data android:name=”android.support.PARENT_ACTIVITY” android:value=”com.example.app_name.A” /> </activity> I also use a theme which provides an UP-button. So after I called activity B I […]

android start activity from service

Android: public class LocationService extends Service { @Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); startActivity(new Intent(this, activity.class)); } } I launched this service from Activity In Activity if condition satisfies start startService(new Intent(WozzonActivity.this, LocationService.class)); from my LocationService mentioned above could not launch Activity, how can I get context of current running Activity […]

requestFeature() must be called before adding content

I am trying to implement a custom titlebar: Here is my Helper class: import android.app.Activity; import android.view.Window; public class UIHelper { public static void setupTitleBar(Activity c) { final boolean customTitleSupported = c.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); c.setContentView(R.layout.main); if (customTitleSupported) { c.getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.titlebar); } } } Here is where I call it in onCreate(): @Override public void onCreate(Bundle savedInstanceState) { […]

Prevent Android activity dialog from closing on outside touch

I have an activity that is using the Theme.Dialog style such that it is a floating window over another activity. However, when I click outside the dialog window (on the background activity), the dialog closes. How can I stop this behaviour?

Activity, AppCompatActivity, FragmentActivity, and ActionBarActivity: When to Use Which?

I’m coming from iOS where it’s easy and you simply use a UIViewController. However, in Android things seem much more complicated, with certain UIComponents for specific API Levels. I’m reading BigNerdRanch for Android (the book is roughly 2 years old) and they suggest I use Activity to host my FragmentActivities. However, I thought Activity was […]

Difference between onCreate() and onStart()?

Possible Duplicate: Android Activity Life Cycle – difference between onPause() and OnStop() I was wondering – what is the difference between onCreate() and onStart() methods? I think that onStart() is a redundant method. onCreate() will ALWAYS be called (At least in my last two projects). Can any one explain the difference?

Android get hosting Activity from a view

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 […]

getActivity() returns null in Fragment function

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 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 […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.