oncreate

How to make notification resume and not recreate activity?

时光怂恿深爱的人放手 提交于 2019-11-27 14:29:20
问题 I thought I had this figured out, but after some debugging on this question: How to make notification uncancellable/unremovable I just realized my activity is still getting onCreated() and onDestroyed(), in random order. My manifest for the activity: <activity android:name="***.***.***.*****" android:configChanges="orientation|keyboardHidden" android:label="@string/app_name" android:screenOrientation="portrait" android:launchMode="singleTop" > <intent-filter> <action android:name="android

Android service onCreate is called multiple times without calling onDestroy

ぐ巨炮叔叔 提交于 2019-11-27 13:18:38
In my app, I use a service to communicate with our server. The Service spawns several message queue threads to deal with tasks with different priorities. This model has been used for about one year without big issues. However, recently, I found some time the onCreate of my service class are called multiple times. onDestroy is never called between two onCreate calls. Therefore, I did not get chance to kill existing threads. Once this behavior happens, the service has duplicate threads inside. The only thing I have changed is to run the service as foreground service is a user signs in the app. I

Android: findViewById returns Null even if is after setContentView

做~自己de王妃 提交于 2019-11-27 08:26:24
问题 Here's my code in LoginActivity: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction() .add(R.id.container, new PlaceholderFragment()).commit(); } loginButton = (Button)findViewById(R.id.loginButton); loginButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onLoginButtonClicked(); } });

Android: using getIntent() only within onCreate?

你离开我真会死。 提交于 2019-11-27 06:59:46
问题 In Android (targeting APIs 14-16) I have a MainActivity and a NextActivity . There is no difficulty using intents to start NextActivity from within MainActivity if the getIntent() method is called inside the onCreate() block of NextActivity : public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); int data = 7; ... Intent intent = new Intent(this, NextActivity.class); intent.putExtra("data", data);

java.lang.NoSuchMethodError: No static method setOnApplyWindowInsetsListener

☆樱花仙子☆ 提交于 2019-11-27 05:15:49
I upgraded my android studio to 2.1.3. And now I am getting following error java.lang.NoSuchMethodError: No static method setOnApplyWindowInsetsListener(Landroid/view/View;Landroid/support/v4/view/OnApplyWindowInsetsListener;)V in class Landroid/support/v4/view/ViewCompatLollipop; or its super classes (declaration of 'android.support.v4.view.ViewCompatLollipop' appears in /data/data/com.restroshop.restroowner/files/instant-run/dex/slice-internal_impl-24.2.0_7c318f8d2adb03d07a9def5d35a14e39204ecef2-classes.dex) at android.support.v4.view.ViewCompat$LollipopViewCompatImpl

SQLiteOpenHelper failing to call onCreate?

ⅰ亾dé卋堺 提交于 2019-11-27 03:43:33
I am trying to create a local database on an android phone using sqlite . I have a helper class, shown below, that is used to create the database and provide the "help". I am wanting to create an object of this class in the main part of my code and it create the database and tables there as well. The problem: Whenever i create an object of the class, it does not seem to be calling the onCreate method in the helper. I thought this is supposed to happen. I thought that onCreate was basically a constructor for the class. (I believe i am wrong) So, why is it not calling the onCreate method? Or how

Android: When is onCreateOptionsMenu called during Activity lifecycle?

非 Y 不嫁゛ 提交于 2019-11-27 00:43:06
I put a couple of breakpoints in onCreate (one at the beginning, and one at the end of the method), and I also put one at the beginning of onCreateOptionsMenu . The onCreate method is called first, and before it finishes onCreateOptionsMenu is called. I'm trying to separate the Fragment navigation code in my app, so I have a couple of objects that I delegate onCreateOptionsMenu to depending on if the app is running on phone/tablet (I'm using screen size to determine this, my layout file for large screens has a View I check for after the layout is inflated). The problem I'm having is, I create

Access Fragment View from Activity's onCreate

落花浮王杯 提交于 2019-11-27 00:28:07
问题 I am in the process of making my first app for Android, and I have a Fragment that gets added to my Activity in the Activity 's onCreate() method. The problem I am facing is that I am unable to find any of the views contained within the Fragment from the Activity 's onCreate() method. Other threads have suggested that this is because the Fragment has not yet been inflated, so findViewById() will return null for any views contained within the Fragment . Here is what I mean: Activity: @Override

When does Application's onCreate() method get called?

前提是你 提交于 2019-11-26 19:41:04
问题 In my Android application, I have a DefaultApplication class which extends android.app.Application , and in its onCreate() I bind some services which will be used by my other Activities in this app. Also I have a BroadcastReceiver which listens and receives C2DM Messages. When this receiver receives a message when the application is not running, it will fire a dialog which shows the upcoming message and it will start an Activity of my application. My question is, when I start an activity

super.onCreate(savedInstanceState);

∥☆過路亽.° 提交于 2019-11-26 19:19:48
I have created an Android Application Project and in MainActivity.java > onCreate() it is calling super.onCreate(savedInstanceState) . As a beginner, can anyone explain what is the purpose of the above line? Every Activity you make is started through a sequence of method calls. onCreate() is the first of these calls. Each and every one of your Activities extends android.app.Activity either directly or by subclassing another subclass of Activity . In Java, when you inherit from a class, you can override its methods to run your own code in them. A very common example of this is the overriding of