oncreate

How to access a start of Application (not Activity)

馋奶兔 提交于 2019-12-12 04:54:35
问题 I need to implement very specific code in the start of the application. I mean, not in the start of the activity(onCreate() or onStart()) but in the start of the application. I had one solution which is not good for me, which is to have a base activity called "MyBaseActivity" and then extends from it in all of my activities. This solution is not good for me, because this solution makes me to be able to do only one specific thing in the onCreate of each activity(the specific code I talked

Android. How to move the imageview(set position/margin) when it is created

假如想象 提交于 2019-12-12 03:08:29
问题 I want to put some images in an area at the application start. As the number of images is not a fixed amount, so I have to create images dynamically. I want to set the position/margin of every images while they're created for good balance. I have tried follows, but there is no efficacy. ・After Created, use imageview.layout(). ・Use LayoutParams.margins(). ・Use AsyncTask to set margins. ・activity.runOnUiThread(). This is the code: // After access server, if needed then add a imageview to the 'c

Android start service issue in onCreate of Activity

久未见 提交于 2019-12-12 01:47:08
问题 I have tried to start a service and bind to the service in my Activity's onCreate() method. When I try to call a function from service like commSessionManagerService.startCommandUpperM() afterwards, a NullPointerException occurs. Here is the code that I use to start the service and bind to it: Intent startIntent = new Intent(this, CommSessionManagerService.class); startService(startIntent); Intent bindIntent = new Intent(this, CommSessionManagerService.class); bindService(bindIntent, conn,

Android layout only showing after oncreate method finishes

醉酒当歌 提交于 2019-12-12 00:19:11
问题 I have created (what I thought was) a simple JAVA card game. In JAVA, the game loads the layout (frame) and displays ImageButtons consisting of a square like cardholder image for each player. The cardholders are then populated by random cards from the deck one by one. So, in my onCreate method in Android, my initial layout consists of the cards with the card holder image, and then I run a method in the onCreate method to deal the cards. The problem I have is the initial layout doesn't show up

Opening a fragment in an existing fragment (Master Detail Design)

ε祈祈猫儿з 提交于 2019-12-11 19:55:45
问题 :) I'm having a problem with opening another fragment from an existing fragment in a master detail view in Android. I've tried various solutions, but nothing helped. I have a listview as a menu, where I can click on different items. By clicking on them, the right fragment will be opened. In one special fragment, I want to implement a button which should replace the existing fragment with another one, but this doesn't work. I've added a toast to see if the onclick method works, it does work,

cakePHP - creating new user account, several problems

烈酒焚心 提交于 2019-12-11 17:59:05
问题 I have two tables, users and tokens . Each user have a activated field and each token have the {id, token, user_id, created} fields. The way the app should work is: On the creation, the app will - make sure that the activated field is empty (to avoid manipulations to the submitted data). a token will be created in the tokens table. On update, the app will - NOT create a new token. NOT allow an update of any kind to the activated field. check if a new email has been submitted, and if so: will

java.lang.NullPointerException and Unknown Source

不羁的心 提交于 2019-12-11 08:58:16
问题 I'm having a hard time fixing some issues with my code. I tested it on my phone and it works good. But if I test it on a Galaxy Tab 4, it gives me java.lang.NullPointerException and unknown source in the onCreate() method. public class MainActivity extends ActionBarActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.mainxml); Button butns = (Button) findViewById(R.id.sb1); butns.setOnClickListener(new View

Android: Use setContentView() after Thread finished

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 08:16:41
问题 I want to use the setContentView() method after a thread has completed his task. But how could I realize this, as its not possible to use this method inside the thread? When using this method in the onCreate() method while the thread is running, I also don´t get the correct result, cause the layout wich should be displayed with the first "setContentView(R.layout.load_screen)" is not displayed. My onCreate() Method: protected void onCreate(Bundle savedInstanceState) { super.onCreate

super.onCreate(savedInstanceState) crashes when activity resumes

被刻印的时光 ゝ 提交于 2019-12-11 08:13:52
问题 My app's main activity starts fine, works fine, everything is dandy - but if you switch away to another app and the app is destroyed by the garbage collector, when you move back to the app it'll crash on "super.onCreate(savedInstanceState)". This is my onCreate(): @Override protected void onCreate(Bundle savedInstanceState) { Log.d(LOG_TAG,"Activity Created"); super.onCreate(savedInstanceState); ... //Other stuff that isn't relevent } Pretty straightforward. Except when I switch away using

MapView / MapActivity crash on some devices

那年仲夏 提交于 2019-12-11 07:36:01
问题 I have gone through Google's MapView tutorial and it works fine on the emulator and for example on my HTC Flyer. But for some reason it immediately crashes when starting it on my mobile phone (Samsung Galaxy I9000). The crash happens there, because right at the beginning the Bundle that onCreate() receives is null. I'm compiling against Android 2.3.3. This is installed on the phone as well. The Flyer uses Android 3.0 I'd greatly appreciate any help on this weird issue. This is the excact