Android :: Low Memory Cause Activity.getIntent() To Return Null?
Sep 10, 2009As the title says? Or what situations can cause this method to return null? I would of thought it retained this object always.
View 2 RepliesAs the title says? Or what situations can cause this method to return null? I would of thought it retained this object always.
View 2 RepliesI wrote CustomView Class, and load it in layout. so i trid to find CustomView using findViewById() in activiy to get handle. but findViewById() was return null.
Written Code is like below:
CODE:.........
MapCanvas.java:
CODE:...............
I'm trying to get the ANDROID_ID on two different devices but it always return null on both. I'm using a Google Ion (aka HTC Magic) with firmware 1.6 and a Motorola Milestone with firmware 2.0.
I've been using this small sample to show the id, but it always shows null:
CODE:........................
Do the Android users have the chance to reset the NetworkProvider, so that the location will be null?
I came up with the idea, that its only possible to have that location null, after starting the device the very first time. But also than google will check the location right away for my opinion.
Sure, I'm implementing a default location for this rare case. I just want to know how seldom this case is.
I am doing some android application. I just wonder what will case the managedQuery method return a null value?
I'm building an android app and I'm currently having trouble retrieving a bitmap from an URL.
Here is the code I'm using :
CODE:..........
Everything works fine when the picture's write but when some bytes are wrong, result gets null. I think it's basically expectable as it's written this in the doc of BitmapFactory.decodeStream :
If the input stream is null, or cannot be used to decode a bitmap, the function returns null. The stream's position will be where ever it was after the encoded data was read.
The problem is, my wrong picture is well interpreted by my web browser and I can do so on iPhone platform.
Is there a way to sort of ignore those wrong pixels? maybe with the option parameter?
I have an application with contains multiple activities. The main activity will start the others ( use startActivity() ) depends on user event, when an activity close, it calls finish() and return back to main activity. It appears to behavior like that.
However, the "problem" I see is main activity's onCreate function is called every time. I think the the main activity should be placed in the activity stack and simply push to front when others exit, therefore only onResume, onStart are called. Is there some flag I need to set or I misunderstand the activity behaviro?
In child activity, besides calling finish() or startActivity for main activity, what is other way to move main activity to front?
Experts: My MainActivity launches a SubActivity by calling: startActivityForResult(intent, REQ_CODE); The SubActivity shows a dialog that has two buttons: Yes, No For the dialog, I've the following code: public void onClick(DialogInterface dialog, int whichButton) {/* User clicked OK */setResult(DialogInterface. BUTTON_POSITIVE) ;finish();
View 2 Replies View RelatedI have a main screen with buttons to launch other subactivities. I have to press back button each time to go back to the main screen of my application. How do I finish a child activity and automatically return from the caller?
View 5 Replies View RelatedI'm using the built in sqlite library on the Android platform.
I'm considering adding several general purpose fields that users will be able to use for their own custom applications, but these fields will be blank most of the time.
My question is, how much overhead will these blank fields add to my database? Do null fields even take up per record memory in sqlite? If so, how much? I don't quite understand the inner workings of a sqlite database.
I am following the Parcelable example in the Android developer guide with the intention of having a more complex object that I send to different activities. Right now, my class is a wrapper of a String member. If I put the object in the intent and read it back from the Intent it reads as expected, however, on the receiver side, it is always null-pointer.
View 1 Replies View RelatedI've followed the SearchManager documentation yet am still having trouble making one of my app's activities searchable. From my activity, the Search dialog appears, I enter a query, hit search, my activity reopens, then I see this in the log:
CODE:.....................
It appears to me that everything is fine up until the last three lines. The "NI" lines are getIntent().toString(), getIntent().getAction(), and getIntent().hasExtra(SearchManager.QUERY) respectively.
ActivityManager appears to be starting my activity with the correct action. Then when my activity starts, it contains no action!? What am I doing wrong?
The relevant portion of my manifest is:
CODE:..............................
I am using an Application object to store app-wide instance data--data that I need to remain in existence for the entire lifetime of the app, so the Application class seems like the proper place to put it. I have just finished reading this thread http://groups.google.com/group/android-developers/browse_thread/threa... that goes into pretty good detail and receives confirmation from Googler hackbod as to how the Application class performs--and from that info it seems this strange behavior I am receiving should not be happening...
Basically, every once in a while when I resume my app in any of its Activities (it is still running in memory so onCreate is not called) I get NullPointerExceptions because instance variables in my Application class are returning null when I request them from my Activity (via a getter method in my custom Application class). It seems as if sometimes Android saves the states of my Activities but deletes all my instance variable data... This can't be an Android problem--there must be something wrong with my code.
Has anyone else ever ran into an issue of this kind? Any ideas as to what may be causing this? I'm not going to post my code here as that won't help anyone, but hopefully someone can point me in some helpful directions.
I have built an activity to handle gestures in my Android game and want it to respond to a gesture anywhere on the screen but I am getting this error on the Log:
CODE:...............
I understand I need to allocate a view to the activity and as you will see in my XML, a view called gestures will serve this purpose but I keep getting Inflation errors when trying to inflate the view. Before when this happened to me it was a misspelling of the view name in the XML but that's not it this time I don't think.
How would I properly assign the 'gesture' view to this activity to prevent the errors?
I have defined my activity in my code like this:
CODE:...............
I have created the activity in the main thread in it's doStart() method by saying:
CODE:............
And my XML layout looks like this:
CODE:...................
i seem to have a classic task, yet i can't find any examples on how to do it.i want to download something. well i call a web service and get a response but its pretty much the same.in order to do this i have an activity that starts a service that spawns a thread that does the job.now i would like to use the data i got in the activity that started the service.(i assume that starting another activity to handle the job of displaying the result would be simple)my problem is how does the service notify an activity (the one that started it or another one) of something.
View 1 Replies View RelatedI have a app with 2 activities, A B A has a button that launches a new intent for B. When at B I press home, then launch app again, B is resumed with onResume(). But if after I press home, I use something like taskiller to clear tasks, then I launch app again, it still shows B, but onCreate() is called. What I want for the second situation is for the app to start A instead of B. How can that be done?
View 2 Replies View RelatedI'm looking for a way to resume my activity (which makes phone call) after call ends by user. Currently after user ends a call, it always returns to the phone's native call-log screen instead of the activity that originated the call. Is there any way to prevent or customize this?
View 3 Replies View RelatedIs it possible to configure an android app so that if a user has opened your app, launched numerous activities, then returns to the home screen and relaunches your app again, instead of going to the main activity they will instead be taken to the activity highest on the stack (the most recent activity in your app)?
View 2 Replies View RelatedI have one main activity and one preference Activity. On my first activity I call menu and go on preference Activity by calling startActivityForResult. Code...
View 1 Replies View RelatedI am new in Android. I encounter the following situation, I have a background running service, which will get a keep-updating string from a webpage, I need to show this keep-updating string in my UI through Activity, since this string is get from service, I am wondering, How can the service pass the string to Activity so that activity can render the string on UI.
View 5 Replies View RelatedMy application supports twitter and needs to open browser for OAuth. When the user clicks the Share on Twitter button, the main activity will create another subactivity (TwitterActivity) to handle twitter authentication issues. Here is a flow graph showing how activities are invoked currently. Main is short for MainActivity and Twit for Twitter Activity. startActivity() OAuth intent OAuth callback finish()Main ---------------> Twit ------------> Browser --------------> Twit --------> Browser As you may notice, after the TwitterActivity calls finish() to stop, it will now return back to MainActivity, but Browser instead. How can I make it return back to MainActivity?
View 2 Replies View RelatedNewbie Question from an iPhone developer.
I have called the startActivity(intent) and the new activity loads. How do I go 'back' to the calling activity once a button is pushed. 'Popping' the activity off the stack basically.
I have 3 classes in my example:
Class A, the main activity. Class A calls a startActivityForResult:
Intent intent = new Intent(this, ClassB.class);
startActivityForResult(intent, "STRING");
Class B, this class is a TabActivity:
Intent intent = new Intent(this, ClassC.class);
tabHost.addTab...
Class C, this class is a regular Activity:
Intent intent = this.getIntent();
intent.putExtra("SOMETHING", "EXTRAS");
this.setResult(RESULT_OK, intent);
finish();
onActivityResult is called in Class A, but the resultCode is RESULT_CANCELED instead of RESULT_OK and the returned intent is null. How do I return something from the Activity inside a TabHost?
I realize that the problem is that my Class C is actually running inside of Class B, and Class B is what is returning the RESULT_CANCELED back to Class A. I just don't know a work around yet.
I am trying to get the contacts from the phone but all I can get is the name, the phone numbers return null.
CODE:...............
After about 3 hours, I have figured it out:
CODE:...............
My app crashes with a null pointer exception on the code below. I have an xml preference file under res/xml/defaults.xml
public class Preference extends Activity {
public Preference() {
} public String getPreference(String key)
{ //it still crashes here
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext());
String result = settings.getString(key, null); return result;
} }
My MAIN activity is spawning a child activity that contains a ListView. While this ListView is being populated (through an AsyncTask), an indeterminate progress bar is shown.However, assuming that I am an impatient user and I press the BACK button, the progress bar is cancelled but I am left with a blank screen. I have to press BACK one more time to go back to the MAIN activity.I would like the app to go back directly to the MAIN activity by pressing BACK only once. Can somebody point me in the right direction? I am thinking I should call finish() somewhere but I don't know where to put it.
View 3 Replies View RelatedI have a widget that when clicked opens an activity from same app as the widget. When the activity is closed/dismissed via a button, the user will see the full app window IF the app was previously open/in memory. Is there a way for the activity to finish and return to the home screen and not to an existing instance of the app?
Intent i = new Intent(this,RateIt.class);
i.putExtra("com.sporadicsoftware.NetQ.movie_id",aMovie.title_id);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET|Intent.FLAG_ACTIVITY_NO_HISTORY|Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(context,
0, i, PendingIntent.FLAG_UPDATE_CURRENT);
updateViews.setOnClickPendingIntent(R.id.movie_one_title, pendingIntent);
I'm trying to bring up the standard window for Bluetooth Settings (with Device name, Discoverability etc). However, general approach with startActivity(intent) ends with NullPointerException pointing to BluetoothSettings.java onCreate:135. Checking with the Android code, I've found that at line 135 they get some extras from the intent. So I prepare the same extras (names I've found in android core BluetoothDevicePicker interface) and issue it -- the same effect with NullPointerException. Might be the wrongs names of the extras I prepare? So is there a way I can see those extras (with names especially) from the intent the system itself submits when I open Bluetooth Settings manually acting like a user. Code...
View 1 Replies View RelatedI've managed to incorporate in-app billing into our product but it is failing on one of my two test devices - a Samsung Vibrant / Galaxy S running Android 4.0.3
The transactions themselves are confirming - reserved product ID's and our actual product ID's - but on this particular phone once the response code is received and the app's activity is brought back into view, several variables holding operation-critical values are NULLed out, crashing the app and preventing actions associated with the purchase.
This DOES NOT happen on another test device - an HTC Sense running Android 2.3.4.
Both devices are running Play Store version 3.5.19.
At a loss right now for trouble shooting. If there is a way to extract the product ID from the signedData bundle returned from the Play Store it would be a way for me to side-step the problem.
How would I force the current thread to wait until another has finished before continuing. In my program the user selects a MODE from an AlertDialog, I want to halt executing of the program before continuing as the mode holds important configuration for the gameplay.
new AlertDialog.Builder(this)
.setItems(R.array.game_modes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case 0:
setMode(TRAINING_MODE);
case 1:
setMode(QUIZ_MODE);
default:
setMode(TRAINING_MODE);
break; ............
//continue loading the rest of onCreate();
contineOnCreate(); } })
.create().show();
If this is impossible can anyone give a possible solution?