Android :: Why Does StartActivity Work In One Method And Fail In Another
I'm struggling to understand why startActivity runs properly when copied from a tutorial I found and fails when I make the smallest change.
Code from the tutorial:
CODE:........
That works. When I try to change it to what I would consider a simpler design, I am getting an error.
CODE:........
The error is: The constructor Intent(FirstTwoApps.ButtonHandler, Class) is undefined
Notice that all I did was moved the action from the handleButtonClick() method to the onClick() method. Apparently that is not allowed, but I don't understand why.
View Complete Thread with Replies
Sponsored Links:
Related Forum Messages:
Android :: AddView And Layout Method Doesn't Work Together
In Android when I am adding a view object like ImageView to FrameLayout view and then immediately trying to call layout() method to repositioned the added view object it is not working. But when I call the layout method alone after some new event e.g. touch event then layout() seems to work. This also happens when bringToFront() and layout() is used together, layout() does not seems to work together with other method. Is there any reason why is this like this? Also instead of adding view object in the middle of the screen can it be ADDED at some specific location in FrameLayout?
View Replies!
View Related
Android :: Method OnBackPressed() Of Type FirstGroup Must Override Superclass Method
I'm trying to override the onBackPressed() method of the ActivityGroup class: public class MyClass extends ActivityGroup { @Override public void onBackPressed() { // do something return; } but I'm getting the error The method onBackPressed() of type MyClass must override a superclass method. I'm relatively new to Java, I've seen here that people do it and it works for them Why I'm getting this error? I'm writing an app for android 1.5, could the problem be here?
View Replies!
View Related
Android :: Show Method Definition - Eclipse Recognizes Warning On Method
In Eclipse, when I mouse hover over a built-in method, it displays a method definition including stuff like what the method does, input objects, return objects etc. If I have a yellow line (warning) under the method I'm trying to use, I can't get the mouse-over to show the definition. If I try hitting F3, I get a "The Jar of this class file belongs to container "Android 1.6" How do I show the definition of the method I am using when there is a warning?
View Replies!
View Related
Android :: How Do I Do A StartActivity In BroadcastReceiver?
My use case is to launch one of settings app screen when I receive a certain event in idle state. For which, I added my new intent to PhoneAppBroadcastReceiver() in PhoneApp.java (looks like this receiver handles the misc intents) But when i call startActivity(), The phone seems to go into a panic ex. startActivity(new Intent(this, NetworkSetting.class)); My questions are is this the right approach to go about ? If so 1. How can I launch the activity inside of broadcastReceiver? secondly 2. How do i verify if the activity i want to start is already started?Can the NEW_TASK_LAUNCH be used to verify this ,
View Replies!
View Related
Android :: StartActivity And ActivityNotFoundException
According to the doc, if the intent in startActivity(intent) is not found, there will be an exception raised. Therefore I use a try/catch block. However, even if I use a random string as the intent, the promised exception does not occur.Instead I see a dialog that says: "No application can perform this function". I also get the same dialog if the intent is valid (picked up by an app) but apparently doesn't want to act when the extras are not what the app expects (e.g. my earlier question about Intent.ACTION_SEND and mime types). I am using the 1.5_r2 SDK on an AVD running 1.5, with the app running at version 1.1 (sdk=2). Is this a doc error, a bug or am I misunderstanding something? Can I simply delete the try/catch block?
View Replies!
View Related
Android :: StartActivity From Subclass?
I have a Activity and I have a class which extends this Activity. In this subclass I call: startActivity(new Intent(this, CameraView.class)) Which should start the "CameraView" Activity. However, I always get this error: CODE:........... If it makes any difference the subclass creates a ListView and when a row of the ListView is clicked it calls startActivity();
View Replies!
View Related
Android :: How I Call StartActivity In BradocastReceiver?
I'd like to launch one of settings app screen when I received a certain event in idle state. For that, I added my new intent to PhoneAppBroadcastReceiver() in PhoneApp.java (because it seems this receiver handles the misc intents) But if I called startActivity(), seems phone goes to panic. ex. startActivity(new Intent(this, NetworkSetting.class)); 1. How can I launch the activity inside of bradcastreceiver? 2. If the activity which I want to start is already started, how can I check it? I read can use NEW_TASK_LAUNCH but don't know how to use it. If you have a sample code, could you post it?
View Replies!
View Related
Android :: Activity Events On StartActivity
Is there any event triggered on an activity when I call startActivity("activity_id", myIntent); If the Activity exists already. I pass a parameter to the activity via i.putExtra("someID", someSerializableObject ); and would like to call a method to refresh a WebView. Right now, the call on startActivity brings the activity in the foreground but the webview does not display what i want.
View Replies!
View Related
Android :: StartActivity() In A Subclass Of Dialog?
I have one subclass which extends Dialog class, it seems I can not use startActivity() function to start a new Activity in this subclass which extends Dialog class, how to resolve it? How to start a new Activity in a Dialog subclass? (In my customized dialog subclass, I have one button, when pressed, I would like to have a new Activity start).
View Replies!
View Related
Android : TabHost And StartActivity For Result?
I meet an issue: my activity cannot return result. I created an activity which has one TabHost. I added three tabs using mTabHost.addTab. Every tab will launch an activity(activity A, activity B, activity C). In activity A, it will call startActivityForResult to start activity A1. The issue is activity A cannot get any result after A1 finish. What is the reason? How should I do if I want to get return value?
View Replies!
View Related
Android :: Should StartActivity Always Run Started Activities OnCreate?
I have a main activity and a sub activity.The main activity starts the sub activity using startActivity, and passes an object in the intent.The sub activity reads the object out of the intent in its onCreate action.The sub activity updates the object, then returns to the main activity using startActivity, again passing the updated object back.However, the main activities onCreate function is not called, so the code it contains to read the passed object does not run.Further investigation indicated that the main activity onPause event is firing, i.e. it is only paused when the sub activity runs, so when the sub activity starts the main activity again, it just on Resumes.Does anyone know if there would be any disadvantages if I moved my data restore/store activities to the onResume and onPause events?I'm not using the onCreate saved Instance State, should I be?
View Replies!
View Related
Android :: Calling StartActivity From Outside Of An Activity Context
I have implemented a ListView in my Android application. I bind to this ListView using a custom subclass of the ArrayAdapter class. Inside the overridden ArrayAdapter.getView(...) method, I assign an OnClickListener. In the onClick(View v) method of the OnClickListener, I want to launch a new activity. I get the exception: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? How can I get the context that the ListView (the current Activity) is working under?
View Replies!
View Related
Android :: TaskAffinity Causes New Instance Being Created When StartActivity
I have a problem about taskAffinity of Activity. Activities A and B with the same taskAffinity. A starts B with FLAG_ACTIVITY_NEW_TASK and the B starts A with FLAG_ACTIVITY_NEW_TASK again. Dumpsys activity of system gives us task stack like below: TOP-> A B A According to SDK's reference to FLAG_ACTIVITY_NEW_TASK, the result is supposed to be like below: TOP -> A B If we did not set taskAffinity, A will not be created again but in different task stack from B. (A and B are in different Apps) After a little more research, we found FLAG_ACTIVITY_REORDER_TO_FRONT is what we want. My question is whether SDK' reference to FLAG_ACTIVITY_NEW_TASK is wrong?
View Replies!
View Related
Android : Purpose Of Using Intent.createChooser() In StartActivity()?
When ever we need to send an email in Android we will invoke registered email application using Intent.ACTION_SEND. like the below Intent i = new Intent(Intent.ACTION_SEND); startActivity(Intent.createChooser(i, "Send mail...")); My doubt is why do we need to use Intent.createChooser in startActivity rather than using startActivty(i). Is there any specific reason of using Intent.createChooser()?
View Replies!
View Related
Android :: StartActivity -ForResult - At The Creation Of Main Activity
I would like to display a an access dialog activity at the start of my application. In other words, I would like to start another activity (in dialog theme) as soon as my Main Activity is loaded. But, I know that I can not start an activity while another is creating. I tried to start this activity in the onResume() method : I can see the new activity called, but the Main activity do not respond after closing the new activity. Is there a solution to do this, without using delayed intent ? May i use a special flag for my intent ? I did not find, in the activity cycle, a way to detect the end of activity loading.
View Replies!
View Related
Android :: StartActivity -intent - And Resume To Main Activity
I've got an app that creates an intent for the last.fm android app in which it will start the "recommended" station for my account when i press a button. The trick i'm trying to figure out is how do i get the phone back to my app without the user having to navigate back manually? Once it start the last.fm intent it takes you to the playlist and i need it to resume back to my app automatically.
View Replies!
View Related
Android :: Pass Intent Via StartActivity() To A Running Activity
MyService and MyClient are both running, although MyClient is currently in the background. If MyService sends an Intent to MyClient via: CODE:.............. How do I get this Intent in MyClient? Running this code triggers onResume() in MyClient, but because it's already running, calling getIntent() returns the Intent that initially created MyClient, which is always android.intent.action.MAIN
View Replies!
View Related
Android : StartActivity Intent Fails When Certain Apps Are Running
I am running into a critical conflict of sorts. My app is a remote service which essentially starts an activity when the screen goes to sleep. How it does this is very simple via screen off broadcast receiver and then an explicit intent to start the activity as a new task. The activity is basically in charge of responding to key events and displaying some simple text. Thanks to a few window flags added in 2.0, activities can do this. They can be created in a way that either puts them on top of the lockscreen, or completely dismiss the lockscreen. This way they basically have focus without the lockscreen having to be dismissed by user. The alarm clock in 2.0 uses the flags to wake up the device and show the alarm dialog. I use them to place my activity when the screen sleeps so the user sees a custom wakeup lockscreen. The reason we create it at screen off is to get rid of lag the user experiences at wakeup involving first seeing the lockscreen, then seeing the activity appear. Also doing it immediately at sleep allows it to have focus so it can handle key events effectively. The process works perfectly except in certain apps. So far, it seems the bug is consistent while browser (and even dolphin browser) as well as the facebook app are running. The bug never happens in GTalk or Launcher. It is rare but can still be duplicated in the messaging app every so often. I can't figure out why my activity doesn't get created at sleep while these apps are active. My remote service still gets the screen off broadcast and does the startActivity for the explicit intent, and that's all I get in the log. My onCreate is not being called. Instead it gets called when we wake the screen up again. I have tried, as a control, to hold the partial wakelock starting when my remote service gets created, and the issue persists. So I don't believe it is a problem that the CPU has gone to sleep. Since only these particular apps cause the issue to duplicate, I can't imagine why the activity start fails. What could those apps be doing to interfere with another app's ability to get created? I use singleInstance as the launch mode so that I can ensure that the activity will never be able to be recalled by user process. I want it to go away when user unlocks and it is working fine like this, as long as it is able to be created. The singleInstance ensures I can have the same lockscreen handle an intent to do something specific based on user actions that the remote service monitors. my source code can be viewed on my project page. http://code.google.com/p/mylockforandroid/source/browse/#svn/trunk/myLock/src/i4nc4mp/myLock The issue happens to both my CustomLockService and NoLockService variations. These two services will start Lockscreen or ShowWhenLockedActivity and the bug is witnessed. The build illustrating the bug's end result-- user has to try to unlock 3 times due to the bug because on wakeup when the oncreate finally succeeds, user is seeing the activity when normally it would have auto-dismissed thanks to key event logic that also isn't seeming to happen due to the delayed onCreate, so they have to send it to sleep again. Now that the activity is properly done being started, and screen is asleep, the expected functionality happens at next wakeup-- can be downloaded also from the downloads tab. This seems like an extremely irrational thing to be caused only by specific apps. I am quite baffled and out of ideas for a solution unless I've made some critical mistake in my activity definitions.
View Replies!
View Related
Android :: Update Intent Of An Existing Activity While Calling StartActivity
I am having two activities, say activity A and B. Activity A is an ListActivity, and when the items in the list is selected, it will call startActivity() to bring up B. The problem here is that when I am in B and click the home key, and then go to the application launcher to resume my application, A will be brought up again. This time when I click a different item in A, it will bring up B with the old data of the previously selected item before the home key was clicked. After examinzing the code, I found that the startActivity does not update the intent of B. I found a post here about the similar question, and the answer was to overwrite the onNewIntent. However, I found that it doesn't work, because this method never get called when the second time I call startActivity. I am sure that this is the same instance, because I've printed out the instance number. Is there any other ways to update the intent of the activity? Or I need some other settings to make the onNewIntent get called? I didn't set any flags or launch modes, so everything is default.
View Replies!
View Related
Android :: Fail To Connect To Camera
I'm using the Android APIDemo sample code. When I run the CameraPreview example, at first it was giving me an error.(http://stackoverflow.com/questions/2556389/android-camera-functionality-howto) I traced that one down and the sample was working for a while. Now, it no longer works. It says ERROR/AndroidRuntime(2949): java.lang.RuntimeException: Fail to connect to camera service What can be causing that? It happens when camera.open() is called.
View Replies!
View Related
Android :: Why SQLiteOpenHelper.onUpgrade Fail?
Every time i increase my database version and push the upgraded app to the users, something weird happens.. For some it works perfectly fine, and some report crashes (including through the Market's reporting system) caused by the lack of table columns i just added in onUpgrade. If you want to see the method: http://code.google.com/p/tag-todo-list/source/browse/trunk/Donut/src/com/android/todo/data/ToDoDB.java#136 I can't spot any exceptions that appear in onUpgrade. What i'm currently doing to bypass these problems is intercepting the exceptions where the new fields are invoked for the first time and then calling onUpgrade 'manually', which is kind of dirty. Also, the app sometimes generates a 'no such table' SQLiteException when accessing the main table (again, only for some users) which is incredibly strange... Does someone know why these things happen? Or can you spot something wrong in my code?
View Replies!
View Related
Android :: When Going On Any Droid App - It Says Login Fail
I have a problem with my Motorola Droid; When i try to go onto one of my droid apps; and when i log on... it says "Login fail" WHat cando i have to do in order to go back to being able to login to my apps? This includes my Meebo app, Yahoo Messeneger app. and my photobucket app will not let my download a pic. to my phone, I use to be able to do all of this, but now it isnt working.
View Replies!
View Related
Android : Fail To Launch SDK 2.0 Tool On OS X
I downloaded the SDK 2.0 toolkit and tried to launch the android tool to download the latest SDK. The application seems to launch with the following output: $ ./android-sdk-mac/tools/android Starting Android SDK and AVD Manager No command line parameters provided, launching UI. See 'android --help' for operations from the command line. $ That's it. Nothing happens, no UI appears or any processes are started (check with ps, but there is no new java process). I'm running this on Mac OS X 10.5.8. The previous SDK s runs fine.
View Replies!
View Related
Android :: Fail To Connect Camera Service On G1
I apologize in advance for this long post, but it's necessary to show what is happening. I've been working on an app that works on the 1.6 emulator, but bombs on my G1. Here is the Photographer activity: CODE:.......... And here is where this activity gets called from: CODE:............ Having trouble pasting the relevant portions of AndroidManifest.xml, but I have permissions for Camera: CODE:.......... Here's the Photographer part: CODE:.............. Also set for testing on G1: android:debuggable="true" and working off of 1.6: <uses-sdk android:minSdkVersion="4" /> All this works on a 1.6 emulator, but when I run this on the G1, LogCat shows: CODE:............. And /data/anr/traces.txt shows: CODE:................ It sounds like the problem is a timeout issue, but I am at a loss as to where I should be looking ....
View Replies!
View Related
Android :: Fail To Connect Camera Service
I had my camera set to this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); and it works fine but if I change it to PORTRAIT instead of LANDSCAPE then it crashes with the following error... CODE:............ The method it crashes in is.. CODE:......... It crashes at mCamera = Camera.open(); My Manifest file has <uses-permission android:name="android.permission.CAMERA"></uses-permission> How do I fix this so I can view my app in Portrait?
View Replies!
View Related
Android :: Fail To Install Maps.apk On Cupcake
I was unable to install Maps.apk into emulator cupcake. I've tried 2 method, both are failure. 1. adb install Maps.apk --> [INSTALL_FAILED_MISSING_SHARED_LIBRARY] 2. Copy Maps.apk to /system/app/, com.google.android.maps.jar to / system/framework/, com.google.android.maps.xml to /etc/permissions/ Map application is still invisible, can anyone help me how to accomplish this issue. Or there's other security issue?
View Replies!
View Related
Android :: Fail To Create A New File On A Sdcard
I do not know what is cause of failing to create a new file on a sdcard of G1, the code is below: File temp = File.createTempFile("test", ".temp", Environment.getExternalStorageDirectory()); and the permission of sdcard is: d--rwxr-x. Also fail if I try using the code below: File file = new File(Environment.getExternalStorageDirectory (),"media.temp"); file.createNewFile(); Giving out about Parent directory of file is not writable.
View Replies!
View Related
Android :: Froyo Only Support Application Uploading Fail
I make application using Froyo SDK.It support only Android 2.2.It is working well on Emulator and Nexus one.but android market uploading error like below.The file is invalid: W/ResourceType(12468): Bad string block: last string is not 0-terminated ERROR getting 'android:label' attribute: attribute is not a string value.If change android:minSdkVersion to 7, then no uploading error.But application only support Froyo.
View Replies!
View Related
Android :: Pandora Fail To Load Songs And Lockup
Dunno what's going on. When I first got my phone Pandora was flawless. Then after awhile it would fail to load songs and lockup (I'd have to kill the process and restart Pandora to get it to work again). Then it got to the point where it would randomly stop mid-song and just skip ahead on its own or fail completely. Now it won't even load. None of my stations load at all. I'd rather not have to resort to using a different service, since I have my Pandora stations setup nearly perfectly
View Replies!
View Related
Android :: Gmail Application Fail - Inbox View Only Seen
You think that google would put forth a much better effort for the email app on Android but ironically, its just a giant epic fail Inbox view only? WTF was Google thinking? It really does suck that i have to use the web app in order to have the full functionality of gmail. I understand Google is moving forward with web apps and the cloud and all that but damn, they leave us hanging like that?
View Replies!
View Related
HTC EVO 4G :: Android Lock Screen - Sense Alarm - Fail
I decided to rename HtcLockscreen.*, which effectively disables the Sense lock screen, and the phone defaults to the Android lock screen, which IMO looks a lot better and provides more function and information. This morning, I discovered the downside of doing so. I had no way to shut of my morning alarm, which is set with the Sense clock app/widget. Normally, the alarm app communicates with the lock screen to give me an option to snooze/dismiss via the lock screen. But evidently, the alarm doesn't know how to communicate with the android lock screen. So the only way I could figure out how to silence the phone was to power it down. I ended up downloading an alarm clock app, and I'm now using that instead of the Sense alarm. Everything is good again. I was just wondering if anyone had a more elegant solution to this problem. I will not consider lockscreen apps like WidgetLocker.
View Replies!
View Related
Android :: Fail On Trying To FindViewById For Nested TextView - Within ListView
Trying to have a ListView (scrollable list) of rows made of two TextViews. I have a list of items from a database that I want to populating into the LinearLayout->ListView->TextView but can't get to the id... Layout somewhat like this instructional link, but have backed away from RelativeLayout and using LinearLayout to get it working. Not even worried about how it looks yet; just can't get it wired together yet. http://android-developers.blogspot.com/2009/02/android-layout-tricks-1.html Have two XML files (very abbreviated details below) CODE:........... I have an ArrayAdapter where I inflate the stuffView. My thinking and understanding of other examples is it's not inflated (this nested stuffView) until I purposely inflate it. That all works fine but when I do the findViewById it returns null and thus I can't setText(). epic Fail due to complete ignorance/newbieness on my part. Note: I've pored through what I can of Reto's book, especially a simliar example on Page 163 but fail fail fail... Can some kind soul point me in the right direction? Must I inflate this nested view? (Reto's example does). If so, what am I missing? I'm hoping someone can point me to a better example. My code's probably too involved at this point to post and a bit proprietary. CODE:........ A pojo called Thingy (not copying Thingy.java here - very simple) The main class: CODE:........... So this code is in essence what I'm looking for help on; neutered the names to call it Thingy.... This sample isn't triggering the getView(). That's a secondary problem I have to sort out. More importantly, your help on the findViewById failure and if I've got the XML right would help a bunch.
View Replies!
View Related
HTC EVO 4G :: Phone Repeater Fail
I try to make a repeater connection with an encore repeater router but the router recognize or detect the wifi signal of the phone and don't make a repeater connection. I test the router with others wifi signals and in make a repeater connection. The icon of the phone in the computer signal detection is like a home group connection.
View Replies!
View Related
|