Android :: SetContentView Fails / When Creating New Activity

Jan 19, 2010

My code is calling setContentView(R.layout.someLayoutID); from an activities' onCreate method. The activity is launched with the following: Code...

Android :: SetContentView fails / when creating new activity

SetContentView Of Activity Within Activities Current View?

Feb 17, 2012

So I have my main activity. It starts out adding a custom SurfaceView called DrawView as the content view with

DrawView drawview = new DrawView(parameters);

now my layout.main.xml is a layout with a video view which I am using to play my cutscenes. I am able to switch to this view by calling a method I made which switches the content view by


which works fine when I am calling this method within the Activity. Only problem is I need to call this method from within DrawView! The method I made to switch to my cutscene is public and I do pass the Activity (named Draw) as a parameter of DrawView.

So when I do call this method from within DrawView my game freezes and will subsequently crash! however it works when method is called locally?

View 3 Replies View Related

Android :: Opening A Second Activity And Fails To Launch?

Apr 12, 2010

What i'm trying to do is to open an Activity when i click on a button.

This is my code in my main activity.


The program launches no problem when i just implement the first button (restuarant).

But when i try to implement the button that i have commented out it fails to launch. and yes i have added the activity to the manifest file.

View 1 Replies View Related

Android :: Adding Data To Intent Fails To Load Activity

Apr 11, 2010

I have a widget that supposed to call an Activity of the main app when the user clicks on widget body. My setup works for a single widget instance but for a second instance of the same widget the PendingIntent gets reused and as result the vital information that I'm sending as extra gets overwritten for the 1st instance. So I figured that I should pass widget ID as Intent data however as soon as I add Intent#setData I would see in the log that 2 separate Intents are appropriately fired but the Activity fails to pick it up so basically Activity will not come up and nothing happens (no error or warning ether)

View 1 Replies View Related

Android :: AsyncTask To Run On Activity Start Fails After Previously Getting Cancelled

Sep 10, 2010

I am using an AsyncTask to fetch the ring tone for a contact when my application starts, it works fine until after my Activity closes a couple of times during the AsyncTask, after this happens the AsyncTask will only ever get to onPreExecute() and never doInBackground, so I can never fetch the ringtone then until either a force stop or device restart.

Why this might be happening? Why the AsyncTask would get to onPreExecute but then never run doInBackground()?

Here is my code: (Following the Shelves source code)


And onAddRingtone() is used in onCreate and onCancelRingTone() is used in onDestroy() as well as where you can see if in the code above. I have spent 3 days on this and I haven't been able to find a solution? Am I taking the wrong approach? Using cancel wrong? Is there a bug?

View 1 Replies View Related

Android :: Can I Start Activity Without Creating A New One?

Jul 31, 2010

In a broadcast receiver I want to do the following:
1. See if MyActivity is alive somewhere. 2. If it is, bring it to the foreground. 3. Otherwise, start a new MyActivity.

View 3 Replies View Related

Android :: Can't Get Layout Info / When Creating Activity

Jul 22, 2010

I have this element in my layout XML:
<FrameLayout android:id="@+id/FrameLayout01"
android:layout_width="320sp" android:layout_height="380sp"
android:layout_gravity="center" android:background="#99CC33">
And I want to get its position on the screen with getTop(), getBottom() but I want to do it only once.
I was trying to do it on the onCreate(), but those methods return all 0 as response.

View 1 Replies View Related

Android :: Creating A Stub Of An Activity In Testing Project

Jul 22, 2010

I want to create a stub of one of my Activities, but I want to keep it in the test project so not to have it in the actual apk. I don't seem to be able to find a way to do it though. I get this:

java.lang.RuntimeException: Unable to resolve activity for: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.example.test.StubActivity }

I did find if I put it in the main project and put it in the manifest accordingly (IntentFilter:(Action:Main, Category:Default)) it will work, well it actually crashed, but I am not bothered by that. Something to fix later on.I did think about putting everything in the same main project and just have a test package, but that would then involve messing the manifest, I think. It seems better to keep them separate. It's just cleaner.

View 1 Replies View Related

Android :: Extracting Activity Code And Creating Graph View Class

Mar 1, 2010

I had a bunch of code in an activity that displays a running graph of some external data. As the activity code was getting kind of cluttered, I decided to extract this code and create a GraphView class:

public class GraphView extends LinearLayout {
public GraphView(Context context, AttributeSet attrs) {
super(context, attrs);
LayoutInflater inflater = (LayoutInflater)
inflater.inflate(R.layout.graph_view, this, true);
public void start() {
// Perform initialization (bindings, timers, etc) here
public void stop() {
// Unbind, destroy timers, } }

Moving stuff into this new LinearLayout-derived class was simple. But there was some lifecycle management code associated with creating and destroying timers and event listeners used by this graph (I didn't want this thing polling in the background if the activity was paused, for example). Coming from a MS Windows background, I kind of expected to find overridable onCreate() and onDestroy() methods or something similar, but I haven't found anything of the sort in LinearLayout (or any of its inherited members). Having to leave all of this initialization code in the Activity, and then having to pass it into the view seemed like it defeated the original purpose of encapsulating all of this code into a reusable view. I ended up adding two additional public methods to my view: start() and stop(). I make these calls from the activity's onResume() and onPause() methods respectively. This seems to work, but it feels like I'm using duct tape here. Does anyone know how this is typically done?

View 4 Replies View Related

Android :: Independent Thread That Executes While Creating Layout And Defining Activity?

Jun 3, 2010

The android docs say that it adds the runnable to the queue and it runs in the UI thread. What does this mean? So, for example, the same thread I use to create my layout is used to run the Runnable? What if I want it as an independent thread that executes while I am creating my layout and defining my activity?

View 2 Replies View Related

Android :: Way To Refresh An Activity / Map View Refresh Fails?

May 3, 2010

After implementing some Android Apps, including several Map activities, I try to refresh the activity when the GPS listener's onLocationChanged() mehtod is called. I have no idea how to tell the map activity to refresh on its own and display the new coords. the coords to store will have to be in global values, so that the location listener will have access to it. In my sample GPS-class (see code below) I just changed the text of a text view....but how to do that in map view?

View 2 Replies View Related

Android :: Use FindViewById Before SetContentView

May 24, 2010

I am creating a layout through code and want to add a View to that layout. The view which is to be added is defined in the xml file. Is there any way to use an View from xml before calling setContentView method. Because we can not call findViewById before setContentView.

View 2 Replies View Related

Android :: Test A Call To SetContentView?

May 25, 2010

How do I write a unit test to determine that the layout used in setContentView(int layoutId) has been called and corresponds to the proper layout for a given activity?

View 1 Replies View Related

Android :: Add Some Button Dynamicly After SetContentView?

Feb 3, 2010

I have use setContentView(R.layout.main) in the onCreate as using XML to set my whole layout.

But now I need add some button dynamicly in the code so I think I need get the layout of the Activity again.

So need I get the laytout of the activity again? If I am right, how to get it?

View 4 Replies View Related

Android :: Customizing Alert Dialog Using SetContentView And Other Api's

Sep 7, 2009

I want to custmize an alert dialog. I can set the content using setContentView and other api's, but Android always gives a white border with rounded edges around the Alert dialog. Is it possible to remove this white border from the dialog box?

View 4 Replies View Related

Android :: ListView OnListItemClick Setcontentview Crash?

Nov 3, 2010

I have been trying to set a new xml layout, when a particular item on this list is clicked.
Am I missing something, because the emulator crashes when clicked?! setContentViewById( file)

public class intentProject extends ListActivity

ListView list;
ArrayAdapter<String> aa;
List<String> data = new ArrayList<String>();

public void onCreate(Bundle savedInstanceState)

View 1 Replies View Related

Android :: SetContentView : Unable To Set TextView From Xml File / Fix It?

Sep 26, 2009

I see a strange problem when I try to set a TextView, instead of a layout file via setContentView.

Case 1: i.e. if I do the following, it works fine...

TextView tv = new TextView(this); tv.setText("Hello World"); setContentView(tv);

Everything is OK.

Case 2: But suppose I have a main.xml file with a TextView in it and I try the following:

=========== View tv = findViewById(; setContentView(tv); =========== I get a Force Close with the below error

09-27 00:08:26.620: ERROR/AndroidRuntime(1595): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f050001 type #0x12 is not valid 09-27 00:08:26.620: ERROR/AndroidRuntime(1595): at android.content.res.Resources.loadXmlResourceParser( 1801) 09-27 00:08:26.620: ERROR/AndroidRuntime(1595): at android.content.res.Resources.getLayout( 09-27 00:08:26.620: ERROR/AndroidRuntime(1595): at android.view.LayoutInflater.inflate( 09-27 00:08:26.620: ERROR/AndroidRuntime(1595): at android.view.LayoutInflater.inflate( 09-27 00:08:26.620: ERROR/AndroidRuntime(1595): at 22)

Case 3: I even tried to inflate the xml and set the view but even that resulted in a force close.

Am I missing something here ?

View 2 Replies View Related

Android :: Show Dialog While Loading Layout By SetContentView In Background

Apr 15, 2010

I am using below code where , i want to show dialog in front and loading content in background but not able to do the same .code...

View 3 Replies View Related

Android :: App Crashes While Putting SetContentView In Thread Class In Emulator / Solve It?

Apr 15, 2010

When I put the setContentView in thread as below, it crashes while running in emulator. code...

View 2 Replies View Related

Android :: Adb Remount Fails On 1.5

May 13, 2009

I have upgraded my phone's images to Android 1.5 images (from Now when I try commands like adb remount, chmod, adb push etc I get "Operation not permitted" and "Permission denied" errors

I was able to give this command when I had 1.0 images flashed on my phone.

Has something related to permissions changed with Android 1.5?

View 2 Replies View Related

Android :: App Fails To Launch?

Apr 16, 2010

I'm trying to do is open a very simple application that is supposed to do nothing but display an imageView above a textView. The application worked fine until I added the imageView so I'm assuming my problem has something to do with that.

Here is the code:


Here is my layout -> main.xml


When I try and run the app in Eclipse through the Emulator the emulator gives me the following error:

The application Application Name ( has stopped unexpectedly. Please try again.

The Console log in Eclipse shows the following messages:


View 1 Replies View Related

Android :: SDK Fails To Install ?

Jan 6, 2010

When I try to install the android SDK it fails to install.

My OS is Windows XP. I just downloaded and installed Java JDK 1.6 Java -version from the command line returns: java version "1.6.0_17" Java(TM) SE Runtime Environment (build 1.6.0_17-b04) Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)

My environment vars have: JAVA_HOME=c:progra~1javajdk1.6.0_11. I downloaded I unziped it in V:AndroidInstall

When I go to the V:androindinstallandroid-sdk-windows> and type "SDK Install.exe" nothing happens...If I go this from graph

When I do this from a graphical file viewer I get a quick flash that looks like a command line window and nothing....

When I try to run android list targets from the tool directory I get:

Error: Error parsing the sdk.
Error: V:androindinstallandroid-sdk-windowsplatforms is missing.
Error: Unable to parse SDK content.

So the basic install setup is not happening.

Additional clues:

I have a G1 and Android 1.0 was running on this machine. (Almost a year ago) I've updated my G1 to 1.6 so I thought I'd update my SDK before starting new development.

When I tried to upgrade it tried and then died as the "directory was in use"
So I cleaned out all the android directories, rebooted and redownloaded everythign from scratch.
Now it won't run at all.

I've clearly got something in an unhappy state, but I've cleaned up all the directories and no remanants seem to be running I've rebooted....

View 3 Replies View Related

Android :: SAXParser Fails On Some RSS Feeds

Feb 28, 2009

I'm using the SAX parser to read some RSS feeds and have found a problem. Some feeds, for example CNN Money Top Stories, have embedded some characters in their content, i.e. the copyright symbol. Well, that's not valid XML and the SAX Parser fails with an exception "invalid token". The only help I have seen given is to fix the XML at the source and that's not an option obviously. So, I can think of 2 options and they both stink:

(a) read the content first, scrub it, and then pass it to the parser.
(b) Use DOM instead of SAX.

What I *want* to do is make the parser a little more forgiving and just accept or discard/ignore the bad text. I'm not have any luck with setErrorHandler. My error handler does not get called.

View 7 Replies View Related

Android :: Camera Prepare Fails

Sep 10, 2009

I'm trying to build a simple video recorder for an Android device and I've had limited success and mixed results. It worked once, but now, without changing anything, I'm getting a "Camera is not available" error followed by "prepare failed -2147483648" error.

View 1 Replies View Related

Android :: GeoCoding Fails After SDK Upgrade To 8

Sep 24, 2010

I recently upgraded my SDK from 7 to 8. One of my applications uses Google GeoCoding, specifically the Geocoder object. After the upgrade, when I call the getFromLocation method, it doesn't return any addresses and I see a message in the logcat to the effect that GLS failed with status 20. My Google Maps API key is working fine because I'm seeing the map tiles, but GeoCoding is broken. It works fine if I run a previous (SDK 7) build of my app.

View 6 Replies View Related

Android :: Market Update Fails

Oct 3, 2010

I want to upload an upgrade in the market. But when I upload the apk and new images and click save or publish everything is lost when I return to the listing (the old apk and images are restored). The only thing that changes is the saved versioncode of the app. Is there something broken?

View 2 Replies View Related

Android :: Mkdir() Fails When Min Sdk Version Is 4

Sep 11, 2010

The following code works when I either have no min sdk version specified in the app manifest or if it's 5 or greater. But if I set the min sdk level to 4 (Android 1.6) , it fails to create a subdirectory in the sdcard.

There is no error. mkdir() or mkdirs() just returns false.


Am I doing something wrong here? Or is this a bug? I'd prefer not to set the target to 2.1 and min version to 1.6. But right now, I have to set it to 2.0 for it to work.

View 8 Replies View Related

Android :: File-creation Fails?

Apr 28, 2010

I use the following code to create a folder "mymir" and a file ".nomedia" (in the mymir-folder) on the sdcard of an android unit. However, somehow it fails with the exception that the folder the ".nomedia"-file is to be placed in dosn't exist.

Here's the code:


View 1 Replies View Related

Android : ContentProvider Fails On Insert

Jul 30, 2010

I am brand new to developing for android and have hit something of a stumbling block that I cant seem to get around.

Using the NotePad example, I have created my own ContentProvider to serve up data from a database that I will eventually host on a webserver. But that is lightyears away from where I am right now.

Just testing my ContentProvider has caused a bit of a headache that I cant solve. For some reason, when the provider calls SQLiteDatabase db = mOpenHelper.getWritableDatabase(); I get a null pointer exception.

Code Follows:


Stack Trace


View 1 Replies View Related

Android :: APK Installation Fails / Package Conflict

Mar 24, 2009

I'm testing an app I'm developing and asked a friend to install on their device. I wanted to make it as easy as possible for them to help me out so I put the .apk up on my website for them to download to the phone (rather than making them download the SDK and use adb to install). The install of the downloaded .apk fails, complaining of a package conflict.

I have since gotten my hands on the phone briefly and I verified that:
* they have selected "allow unsigned apps" in settings
* there is no package with the same (or similar) name in data/data * installing via adb works with not a peep
* when I download the .apk to my phone the app installs fine.
It would be really nice to make it as easy as possible to distribute to people who might be willing to do me the favor of testing.

View 3 Replies View Related

Copyrights 2005-15, All rights reserved