App is crashing! - Java for Android App Development

Hey, i was working through intent, when I encountered this error. My app seems to crash, when any of the button is clicked..
Please help me out.. I am providing all the codes..
manifest:
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.intent"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="8" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.intent.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
main_activity.xml:
Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10sp" >
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="onClickWebBrowser"
android:onClick="onClickWebBrowser" />
<Button
android:id="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button1"
android:layout_alignParentBottom="true"
android:text="oClickMakeCalls"
android:onClick="onClickMakeCalls"/>
<Button
android:id="@+id/button3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/button1"
android:layout_centerVertical="true"
android:text="onClickShowMap"
android:onClick="onClickShowMap" />
</RelativeLayout>
MainActivity.java:
Code:
package com.example.intent;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
public class MainActivity extends Activity {
int request_code = 1;
[user=439709]@override[/user]
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void onClickWebBrowser(View v) {
Intent i = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("www.crazyandroidgalaxy.blogspot.in"));
startActivity(i);
}
public void onClickMakeCalls(View v) {
Intent i = new Intent(android.content.Intent.ACTION_DIAL,
Uri.parse("01123235616"));
startActivity(i);
}
public void onClickShowMap(View v) {
Intent i = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("“geo:37.827500,-122.481670”"));
startActivity(i);
}
}
logcat:
Code:
07-11 12:46:55.290: D/AndroidRuntime(284): Shutting down VM
07-11 12:46:55.290: W/dalvikvm(284): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
07-11 12:46:55.569: E/AndroidRuntime(284): FATAL EXCEPTION: main
07-11 12:46:55.569: E/AndroidRuntime(284): java.lang.IllegalStateException: Could not execute method of the activity
07-11 12:46:55.569: E/AndroidRuntime(284): at android.view.View$1.onClick(View.java:2072)
07-11 12:46:55.569: E/AndroidRuntime(284): at android.view.View.performClick(View.java:2408)
07-11 12:46:55.569: E/AndroidRuntime(284): at android.view.View$PerformClick.run(View.java:8816)
07-11 12:46:55.569: E/AndroidRuntime(284): at android.os.Handler.handleCallback(Handler.java:587)
07-11 12:46:55.569: E/AndroidRuntime(284): at android.os.Handler.dispatchMessage(Handler.java:92)
07-11 12:46:55.569: E/AndroidRuntime(284): at android.os.Looper.loop(Looper.java:123)
07-11 12:46:55.569: E/AndroidRuntime(284): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-11 12:46:55.569: E/AndroidRuntime(284): at java.lang.reflect.Method.invokeNative(Native Method)
07-11 12:46:55.569: E/AndroidRuntime(284): at java.lang.reflect.Method.invoke(Method.java:521)
07-11 12:46:55.569: E/AndroidRuntime(284): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-11 12:46:55.569: E/AndroidRuntime(284): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-11 12:46:55.569: E/AndroidRuntime(284): at dalvik.system.NativeStart.main(Native Method)
07-11 12:46:55.569: E/AndroidRuntime(284): Caused by: java.lang.reflect.InvocationTargetException
07-11 12:46:55.569: E/AndroidRuntime(284): at com.example.intent.MainActivity.onClickWebBrowser(MainActivity.java:24)
07-11 12:46:55.569: E/AndroidRuntime(284): at java.lang.reflect.Method.invokeNative(Native Method)
07-11 12:46:55.569: E/AndroidRuntime(284): at java.lang.reflect.Method.invoke(Method.java:521)
07-11 12:46:55.569: E/AndroidRuntime(284): at android.view.View$1.onClick(View.java:2067)
07-11 12:46:55.569: E/AndroidRuntime(284): ... 11 more
07-11 12:46:55.569: E/AndroidRuntime(284): Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=www.crazyandroidgalaxy.blogspot.in }
07-11 12:46:55.569: E/AndroidRuntime(284): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)
07-11 12:46:55.569: E/AndroidRuntime(284): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
07-11 12:46:55.569: E/AndroidRuntime(284): at android.app.Activity.startActivityForResult(Activity.java:2817)
07-11 12:46:55.569: E/AndroidRuntime(284): at android.app.Activity.startActivity(Activity.java:2923)
07-11 12:46:55.569: E/AndroidRuntime(284): ... 15 more
07-11 12:46:55.569: E/AndroidRuntime(284): FATAL EXCEPTION: main
07-11 12:46:55.569: E/AndroidRuntime(284): java.lang.IllegalStateException: Could not execute method of the activity
07-11 12:46:55.569: E/AndroidRuntime(284): at android.view.View$1.onClick(View.java:2072)
07-11 12:46:55.569: E/AndroidRuntime(284): at android.view.View.performClick(View.java:2408)
07-11 12:46:55.569: E/AndroidRuntime(284): at android.view.View$PerformClick.run(View.java:8816)
07-11 12:46:55.569: E/AndroidRuntime(284): at android.os.Handler.handleCallback(Handler.java:587)
07-11 12:46:55.569: E/AndroidRuntime(284): at android.os.Handler.dispatchMessage(Handler.java:92)
07-11 12:46:55.569: E/AndroidRuntime(284): at android.os.Looper.loop(Looper.java:123)
07-11 12:46:55.569: E/AndroidRuntime(284): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-11 12:46:55.569: E/AndroidRuntime(284): at java.lang.reflect.Method.invokeNative(Native Method)
07-11 12:46:55.569: E/AndroidRuntime(284): at java.lang.reflect.Method.invoke(Method.java:521)
07-11 12:46:55.569: E/AndroidRuntime(284): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-11 12:46:55.569: E/AndroidRuntime(284): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-11 12:46:55.569: E/AndroidRuntime(284): at dalvik.system.NativeStart.main(Native Method)
07-11 12:46:55.569: E/AndroidRuntime(284): Caused by: java.lang.reflect.InvocationTargetException
07-11 12:46:55.569: E/AndroidRuntime(284): at com.example.intent.MainActivity.onClickWebBrowser(MainActivity.java:24)
07-11 12:46:55.569: E/AndroidRuntime(284): at java.lang.reflect.Method.invokeNative(Native Method)
07-11 12:46:55.569: E/AndroidRuntime(284): at java.lang.reflect.Method.invoke(Method.java:521)
07-11 12:46:55.569: E/AndroidRuntime(284): at android.view.View$1.onClick(View.java:2067)
07-11 12:46:55.569: E/AndroidRuntime(284): ... 11 more
07-11 12:46:55.569: E/AndroidRuntime(284): Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=www.crazyandroidgalaxy.blogspot.in }
07-11 12:46:55.569: E/AndroidRuntime(284): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)
07-11 12:46:55.569: E/AndroidRuntime(284): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
07-11 12:46:55.569: E/AndroidRuntime(284): at android.app.Activity.startActivityForResult(Activity.java:2817)
07-11 12:46:55.569: E/AndroidRuntime(284): at android.app.Activity.startActivity(Activity.java:2923)
07-11 12:46:55.569: E/AndroidRuntime(284): ... 15 more
07-11 12:46:57.890: I/Process(284): Sending signal. PID: 284 SIG: 9
Please help me out! Thanks in advance..

Aren't there prefixes for the Uris?
Try "tel:<your number>" for example for the dial intent. (If that does not work, search for the right prefix.)

Its strange, i got this code from a book (begining android application development.)
How can it be faulty..
I dont find any prefix for the uriS
edit:
Actually, there is a prefix for the dialing intent.
But not, for the browser intent.
So, my app is still cashing
edit: actually, it.worked. But the map is still crashing
Sent from my GT-S6102 using xda app-developers app

Related

[CODE][Q] Pass extra twice(image to mms), or use lastIndexOf() to get file?

Ok so this may get sort of complicated, but I'll try to explain it simply.
I have a mainActivity(viewpager). i take a screenshot of this from ABS options menu. This gets saved to sdcard . WORKS FINE
Code:
this is selecting from the actionbar menu
else if (item.getTitle().toString().equalsIgnoreCase("Take Screengrab")) {
View v1 = R1.getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap bm = v1.getDrawingCache();
Util.saveBitmap(bm, "folder", "screenshot");
//the above are the folder I chose to name, and the screenshotname{without additional numbering}
BitmapDrawable bitmapDrawable = new BitmapDrawable(bm);
image = (ImageView) findViewById(R.id.image4);
//imageview is above. second ativity is below
Intent intent = new Intent(this, Screenshots.class);
intent.putExtra("image", bm);
//"image" is my extra
startActivity(intent);
I send that while its saving, to an ImageView in a second(normal) activity. WORKS FINE
Code:
[user=439709]@override[/user]
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.screenshots);
//The ImageView where the screenshot goes
ImageView image=(ImageView)findViewById(R.id.image4);
//This "imageId" isnt used, but for some reason the Imageview wont set without it
Intent intent = getIntent();
int imageId = intent.getIntExtra("imageId", -1); // -1 would be a default value//
//this gets my extra
Bitmap bm = (Bitmap)this.getIntent().getParcelableExtra("image");
image.setImageBitmap(bm);
I have a button to share it, it opens with picture attached. SORT OF WORKING
The thing is, I want to automatically pass this same extra Bitmap and attach it to the message.
i can open a message with a known file attached.
Code:
{
Uri smsUri = Uri.parse("tel:0000000");
Intent intent = new Intent(Intent.ACTION_SEND, smsUri);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/folder/screenshot.png"));
intent.putExtra(Intent.EXTRA_TEXT,"Today");
startActivity(intent);
i tried the working in putExtra to the message, but I get a toast from the messaging app "Sorry, cannot attach this image". NO STACK ERRORS. nothign in the logs I can use.
Code:
Uri smsUri = Uri.parse("tel:0000000");
Intent intent = new Intent(Intent.ACTION_SEND, smsUri);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("image"));
intent.putExtra(Intent.EXTRA_TEXT,"Today");
startActivity(intent);
and other stuff like that that.
I currently am loading a known file into the message and it works perfect. Problem is, I wont know the name of the file, because my screenshots get saved as image1, image2, etc. So it will be different in every case.
So im wondering if its even possible to pass and extra through twice like that, or if I should look into return the latest image in that sdcard folder with like lastIndexOf(), or something similar.
basically, is there a way to simply query find and attach the highest numbered file? without a GUI(i can do select from gallery, but am trying to make it more automated).
any thoughts would be appreciated.
P.S. i know about the lint errors and things, and somewhat sloppy self taught java, but its working. only worried about the image passing.
out of ideas said:
Ok so this may get sort of complicated, but I'll try to explain it simply.
I have a mainActivity(viewpager). i take a screenshot of this from ABS options menu. This gets saved to sdcard . WORKS FINE
Code:
this is selecting from the actionbar menu
else if (item.getTitle().toString().equalsIgnoreCase("Take Screengrab")) {
View v1 = R1.getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap bm = v1.getDrawingCache();
Util.saveBitmap(bm, "folder", "screenshot");
//the above are the folder I chose to name, and the screenshotname{without additional numbering}
BitmapDrawable bitmapDrawable = new BitmapDrawable(bm);
image = (ImageView) findViewById(R.id.image4);
//imageview is above. second ativity is below
Intent intent = new Intent(this, Screenshots.class);
intent.putExtra("image", bm);
//"image" is my extra
startActivity(intent);
I send that while its saving, to an ImageView in a second(normal) activity. WORKS FINE
Code:
[user=439709]@override[/user]
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.screenshots);
//The ImageView where the screenshot goes
ImageView image=(ImageView)findViewById(R.id.image4);
//This "imageId" isnt used, but for some reason the Imageview wont set without it
Intent intent = getIntent();
int imageId = intent.getIntExtra("imageId", -1); // -1 would be a default value//
//this gets my extra
Bitmap bm = (Bitmap)this.getIntent().getParcelableExtra("image");
image.setImageBitmap(bm);
I have a button to share it, it opens with picture attached. SORT OF WORKING
The thing is, I want to automatically pass this same extra Bitmap and attach it to the message.
i can open a message with a known file attached.
Code:
{
Uri smsUri = Uri.parse("tel:0000000");
Intent intent = new Intent(Intent.ACTION_SEND, smsUri);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/folder/screenshot.png"));
intent.putExtra(Intent.EXTRA_TEXT,"Today");
startActivity(intent);
i tried the working in putExtra to the message, but I get a toast from the messaging app "Sorry, cannot attach this image". NO STACK ERRORS. nothign in the logs I can use.
Code:
Uri smsUri = Uri.parse("tel:0000000");
Intent intent = new Intent(Intent.ACTION_SEND, smsUri);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("image"));
intent.putExtra(Intent.EXTRA_TEXT,"Today");
startActivity(intent);
and other stuff like that that.
I currently am loading a known file into the message and it works perfect. Problem is, I wont know the name of the file, because my screenshots get saved as image1, image2, etc. So it will be different in every case.
So im wondering if its even possible to pass and extra through twice like that, or if I should look into return the latest image in that sdcard folder with like lastIndexOf(), or something similar.
basically, is there a way to simply query find and attach the highest numbered file? without a GUI(i can do select from gallery, but am trying to make it more automated).
any thoughts would be appreciated.
P.S. i know about the lint errors and things, and somewhat sloppy self taught java, but its working. only worried about the image passing.
Click to expand...
Click to collapse
I would just pass the filename to the share intent. In your saving method return the file name and pass it to the Uri.
lastIndexOf is a bad idea. What will you do if somebody saves a file called "xyz" in the same directory? The app will send this every time. So store the filename and pass it to the Uri.
nikwen said:
I would just pass the filename to the share intent. In your saving method return the file name and pass it to the Uri.
lastIndexOf is a bad idea. What will you do if somebody saves a file called "xyz" in the same directory? The app will send this every time. So store the filename and pass it to the Uri.
Click to expand...
Click to collapse
Yeah I had originally tried going about it that, with like getFileStreamPath and things like that, tried about a dozen different things but couldnt get them working. best i can get is that "sorry cant add..." message from the messaging app, which tells me that its passing the image, but it cant attach for some unknown reason(too large doesn't seem right, cuz i can do it with the known file name).
im a dum dum a probably should put this util class
Code:
static String saveBitmap(Bitmap bitmap, String dir, String baseName) {
try {
File sdcard = Environment.getExternalStorageDirectory();
File pictureDir = new File(sdcard, dir);
pictureDir.mkdirs();
File f = null;
for (int i = 1; i < 200; ++i) {
String name = baseName + i + ".png";
f = new File(pictureDir, name);
if (!f.exists()) {
break;
}
}
if (!f.exists()) {
String name = f.getAbsolutePath();
FileOutputStream fos = new FileOutputStream(name);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.flush();
fos.close();
//how to get "name" in third activity
return name;
}
} catch (Exception e) {
} finally {
/*
if (fos != null) {
fos.close();
}
*/
}
return null;
}
So I have the name there, but just cant get it over to the messaging. I'm wondering if I should take the pic and automaticaaly pin it to the MMS, and skip the imageview part?
First: Please get a logcat.
Second: This should be working if you use the right path:
Code:
Uri smsUri = Uri.parse("tel:0000000");
Intent intent = new Intent(Intent.ACTION_SEND, smsUri);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("<path here>"));
intent.putExtra(Intent.EXTRA_TEXT,"Today");
startActivity(intent);
(got it from your first post)
1. This is a for instance situtation of if i try sliding the extra or something else into Uri.parse()
E/Mms/compose( 1063): DRM error in onActivityResult()!
E/Mms/media( 1063): IOException caught while opening or reading stream
E/Mms/media( 1063): java.io.FileNotFoundException: No content provider: image
But the content of image makes it into the ImageView(as "getParcelableExtra("image"), just not in the MMS, so I don't know.
2. Yeah it works Perfect when I hardcode in a file( sdcard/folder/image1.png). attaches and sends perfect.
The problem is basically I have a loose understanding of how I should be doing this, and just cant figure out how I should properly be getting it to load.
Banging my head against the wall on this one. lol. :fingers-crossed:
out of ideas said:
1. This is a for instance situtation of if i try sliding the extra or something else into Uri.parse()
E/Mms/compose( 1063): DRM error in onActivityResult()!
E/Mms/media( 1063): IOException caught while opening or reading stream
E/Mms/media( 1063): java.io.FileNotFoundException: No content provider: image
But the content of image makes it into the ImageView(as "getParcelableExtra("image"), just not in the MMS, so I don't know.
2. Yeah it works Perfect when I hardcode in a file( sdcard/folder/image1.png). attaches and sends perfect.
The problem is basically I have a loose understanding of how I should be doing this, and just cant figure out how I should properly be getting it to load.
Banging my head against the wall on this one. lol. :fingers-crossed:
Click to expand...
Click to collapse
The problem is that you do not pass the right file name. So it cannot find the file.
---------- Post added at 07:55 PM ---------- Previous post was at 07:48 PM ----------
Change it to this and tell us the log output:
Code:
static String saveBitmap(Bitmap bitmap, String dir, String baseName) {
try {
File sdcard = Environment.getExternalStorageDirectory();
File pictureDir = new File(sdcard, dir);
pictureDir.mkdirs();
File f = null;
for (int i = 1; i < 200; ++i) {
String name = baseName + i + ".png";
f = new File(pictureDir, name);
if (!f.exists()) {
break;
}
}
if (!f.exists()) {
Log.d("file", "file does not exist");
String name = f.getAbsolutePath();
FileOutputStream fos = new FileOutputStream(name);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.flush();
fos.close();
//how to get "name" in third activity
if (name != null) {
Log.d("return", name);
} else {
Log.d("return", "name = null");
}
return name;
} else {
Log.d("file", "file exists");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
/*
if (fos != null) {
fos.close();
}
*/
}
Log.d("return", "null");
return null;
}
I just inserted some debugging things. Check the logcat (and post it).
Did you add this to your manifest?
Code:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
nikwen said:
The problem is that you do not pass the right file name. So it cannot find the file.
I just inserted some debugging things. Check the logcat (and post it).
Did you add this to your manifest?
Code:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Click to expand...
Click to collapse
i know! I just need a way to get what my Util class returns as name. then open that attached to Message. It seems like it should be a lot easier than I am making it.
i added your logs, but the only match back I get is here (I put in some extra stuff)
Code:
D/ViewRoot( 2072): Dispatching pointer MotionEvent{2b00f540 action=1 x=85.33334 y=179.98325 pressure=0.20000002 size=0.20000002} to [email protected]
D/dalvikvm( 2072): GC_EXTERNAL_ALLOC freed 82K, 45% free 3083K/5575K, external 2159K/2284K, paused 57ms
//[B]THIS RIGHT BELOW HERE IS THE FILENAME. I NEED TO RETURN IT IN THE OTHER ACTIVITY. But How?
D/return ( 2072): /mnt/sdcard/folder/screen162.png
[/B]
I/ActivityManager( 182): Starting: Intent { cmp=com.myapp/.Screenshots (has extras) } from pid 2072
E/ActivityThread( 2072): >>> handling: 101
W/WindowManager( 182): Reached focused app: AppWindowToken{2b70bbf8 token=HistoryRecord{2b28ff08 com.myapp/.Screenshots}}
W/WindowManager( 182): updateFocusedWindowLocked newFocus=null mode=0 mCurrentFocus = Window{2b332630 PopupWindow:2afbd178 paused=false}
W/WindowManager( 182): Reached focused app: AppWindowToken{2b70bbf8 token=HistoryRecord{2b28ff08 com.myapp/.Screenshots}}
W/WindowManager( 182): updateFocusedWindowLocked newFocus=Window{2b408a60 com.myapp/com.myapp.Screenshots paused=false} mode=2 mCurrentFocus = Window{2b408a60 com.myapp/com.myapp.Screenshots paused=false}
W/WindowManager( 182): updateFocusedWindowLocked newFocus=Window{2b408a60 com.myapp/com.myapp.Screenshots paused=false} mode=3 mCurrentFocus = Window{2b408a60 com.myapp/com.myapp.Screenshots paused=false}
W/WindowManager( 182): Window Window{2b320c38 com.myapp/com.myapp.MainActivity paused=false} destroying surface Surface(name=com.myapp/com.myapp.MainActivity, identity=204), session Session{2b542460 uid 10050}
W/WindowManager( 182): Window Window{2b332630 PopupWindow:2afbd178 paused=false} destroying surface Surface(name=PopupWindow:2afbd178, identity=205), session Session{2b542460 uid 10050}
I/ActivityManager( 182): Displayed com.myapp/.Screenshots: +549ms
W/WindowManager( 182): Reached focused app: AppWindowToken{2b2dfeb8 token=HistoryRecord{2b395530 com.android.mms/.ui.ComposeMessageActivity}}
D/ActivityThread( 2072): <<< done: 106
W/WindowManager( 182): updateFocusedWindowLocked newFocus=null mode=3 mCurrentFocus = null
W/WindowManager( 182): Reached focused app: AppWindowToken{2b2dfeb8 token=HistoryRecord{2b395530 com.android.mms/.ui.ComposeMessageActivity}}
W/WindowManager( 182): Reached focused app: AppWindowToken{2b2dfeb8 token=HistoryRecord{2b395530 com.android.mms/.ui.ComposeMessageActivity}}
W/WindowManager( 182): Reached focused app: AppWindowToken{2b2dfeb8 token=HistoryRecord{2b395530 com.android.mms/.ui.ComposeMessageActivity}}
W/WindowManager( 182): updateFocusedWindowLocked newFocus=null mode=3 mCurrentFocus = null
W/WindowManager( 182): Reached focused app: AppWindowToken{2b2dfeb8 token=HistoryRecord{2b395530 com.android.mms/.ui.ComposeMessageActivity}}
W/WindowManager( 182): updateFocusedWindowLocked newFocus=null mode=3 mCurrentFocus = null
I/ActivityThread( 2081): Pub com.android.mms.SuggestionsProvider:
com.android.mms.SuggestionsProvider
E/MmsCustom( 2081): Mms,MmsCustom
E/MmsCustom( 2081): Init before calling function of doPreSotred()
E/MmsCustom( 2081): mms config have been prestored before
Yeah, I took 162 screenshots so far trying to get this. lol.
And yeah I declared the right permissions and everything. It takes the screenshot, saves it, and passes it to an ImageView in a different activity perfectly.
I can open Messaging, or FB,picassa, etc. It appends the text, but no image. BUT, i can simply hit attach from the opened message, and add in whatever picture I want.
I thought about just sending people into the gallery to pick, but the android numbering convention doesn't load images in sequential order, but a sort of numerical alphabetical( it saves likes 1, 10, 11,12,13,14,15,16,17,18,19,2,20,21,22,etc). At least this is with quickpic.
So they really get jumbled up, especially with 100+ in there(1, 10,100,11,12). And the point of this segment of the app is to share the most recent image.
i also dont want to just use the currentsystem time, because a ton of numbers is too confusing if they want to find a different one.
Thanks a lot for the help.
Let's try:
Code:
[COLOR="Red"]String path = Utils.saveBitmap(bitmap, dir, baseName);[/COLOR] //replace Utils by your class name
Uri smsUri = Uri.parse("tel:0000000");
Intent intent = new Intent(Intent.ACTION_SEND, smsUri);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_STREAM, Uri.[COLOR="Red"]fromFile(path)[/COLOR]);
intent.putExtra(Intent.EXTRA_TEXT,"Today");
[COLOR="Red"]intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);[/COLOR]
startActivity(intent);
Took awhile to get Eclipse to accept it, but now I get
Code:
W/System.err( 2002): java.lang.NullPointerException
W/System.err( 2002): at com.MYAPP.Util.saveBitmap(Util.java:39)
//////The top red line you suggested
W/System.err( 2002): at com.MYAPP.Screenshots.onOptionsItemSelected(Screenshots.java:79)
W/System.err( 2002): at android.support.v4.app.Watson.onMenuItemSelected(Watson.java:119)
W/System.err( 2002): at com.actionbarsherlock.ActionBarSherlock.callbackOptionsItemSelected(ActionBarSherlock.java:603)
W/System.err( 2002): at com.actionbarsherlock.internal.ActionBarSherlockCompat.onMenuItemSelected(ActionBarSherlockCompat.java:529)
W/System.err( 2002): at com.actionbarsherlock.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:738)
W/System.err( 2002): at com.actionbarsherlock.internal.view.menu.SubMenuBuilder.dispatchMenuItemSelected(SubMenuBuilder.java:83)
W/System.err( 2002): at com.actionbarsherlock.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:148)
W/System.err( 2002): at com.actionbarsherlock.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:879)
W/System.err( 2002): at com.actionbarsherlock.internal.view.menu.MenuPopupHelper.onItemClick(MenuPopupHelper.java:158)
W/System.err( 2002): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
W/System.err( 2002): at android.widget.ListView.performItemClick(ListView.java:3513)
W/System.err( 2002): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1812)
W/System.err( 2002): at android.os.Handler.handleCallback(Handler.java:587)
W/System.err( 2002): at android.os.Handler.dispatchMessage(Handler.java:92)
W/System.err( 2002): at android.os.Looper.loop(Looper.java:130)
W/System.err( 2002): at android.app.ActivityThread.main(ActivityThread.java:3822)
W/System.err( 2002): at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 2002): at java.lang.reflect.Method.invoke(Method.java:507)
W/System.err( 2002): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
W/System.err( 2002): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
W/System.err( 2002): at dalvik.system.NativeStart.main(Native Method)
D/return ( 2002): null
D/AndroidRuntime( 2002): Shutting down VM
W/dalvikvm( 2002): threadid=1: thread exiting with uncaught exception (group=0x2aac4560)
E/AndroidRuntime( 2002): FATAL EXCEPTION: main
E/AndroidRuntime( 2002): java.lang.NullPointerException: uriString
E/AndroidRuntime( 2002): at android.net.Uri$StringUri.<init>(Uri.java:420)
E/AndroidRuntime( 2002): at android.net.Uri$StringUri.<init>(Uri.java:410)
E/AndroidRuntime( 2002): at android.net.Uri.parse(Uri.java:382)
//////The Changed Uri.getFile(); Line
E/AndroidRuntime( 2002): at com.MYAPP.Screenshots.onOptionsItemSelected(Screenshots.java:82)
E/AndroidRuntime( 2002): at android.support.v4.app.Watson.onMenuItemSelected(Watson.java:119)
E/AndroidRuntime( 2002): at com.actionbarsherlock.ActionBarSherlock.callbackOptionsItemSelected(ActionBarSherlock.java:603)
E/AndroidRuntime( 2002): at com.actionbarsherlock.internal.ActionBarSherlockCompat.onMenuItemSelected(ActionBarSherlockCompat.java:529)
E/AndroidRuntime( 2002): at com.actionbarsherlock.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:738)
E/AndroidRuntime( 2002): at com.actionbarsherlock.internal.view.menu.SubMenuBuilder.dispatchMenuItemSelected(SubMenuBuilder.java:83)
E/AndroidRuntime( 2002): at com.actionbarsherlock.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:148)
E/AndroidRuntime( 2002): at com.actionbarsherlock.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:879)
E/AndroidRuntime( 2002): at com.actionbarsherlock.internal.view.menu.MenuPopupHelper.onItemClick(MenuPopupHelper.java:158)
E/AndroidRuntime( 2002): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
E/AndroidRuntime( 2002): at android.widget.ListView.performItemClick(ListView.java:3513)
E/AndroidRuntime( 2002): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1812)
E/AndroidRuntime( 2002): at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime( 2002): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 2002): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 2002): at android.app.ActivityThread.main(ActivityThread.java:3822)
E/AndroidRuntime( 2002): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 2002): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 2002): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime( 2002): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime( 2002): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 181): Force finishing activity com.MYAPP/.Screenshots
W/WindowManager( 181)
Starting to think I should just dump the whole imageview thing.
i need to figure out if i can save to SD how I am doing, and ALSO save to a cache (and overwrite other ones, so only one image persists there)
out of ideas said:
Took awhile to get Eclipse to accept it, but now I get
Code:
W/System.err( 2002): java.lang.NullPointerException
W/System.err( 2002): at com.MYAPP.Util.saveBitmap(Util.java:39)
//////The top red line you suggested
W/System.err( 2002): at com.MYAPP.Screenshots.onOptionsItemSelected(Screenshots.java:79)
W/System.err( 2002): at android.support.v4.app.Watson.onMenuItemSelected(Watson.java:119)
W/System.err( 2002): at com.actionbarsherlock.ActionBarSherlock.callbackOptionsItemSelected(ActionBarSherlock.java:603)
W/System.err( 2002): at com.actionbarsherlock.internal.ActionBarSherlockCompat.onMenuItemSelected(ActionBarSherlockCompat.java:529)
W/System.err( 2002): at com.actionbarsherlock.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:738)
W/System.err( 2002): at com.actionbarsherlock.internal.view.menu.SubMenuBuilder.dispatchMenuItemSelected(SubMenuBuilder.java:83)
W/System.err( 2002): at com.actionbarsherlock.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:148)
W/System.err( 2002): at com.actionbarsherlock.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:879)
W/System.err( 2002): at com.actionbarsherlock.internal.view.menu.MenuPopupHelper.onItemClick(MenuPopupHelper.java:158)
W/System.err( 2002): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
W/System.err( 2002): at android.widget.ListView.performItemClick(ListView.java:3513)
W/System.err( 2002): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1812)
W/System.err( 2002): at android.os.Handler.handleCallback(Handler.java:587)
W/System.err( 2002): at android.os.Handler.dispatchMessage(Handler.java:92)
W/System.err( 2002): at android.os.Looper.loop(Looper.java:130)
W/System.err( 2002): at android.app.ActivityThread.main(ActivityThread.java:3822)
W/System.err( 2002): at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 2002): at java.lang.reflect.Method.invoke(Method.java:507)
W/System.err( 2002): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
W/System.err( 2002): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
W/System.err( 2002): at dalvik.system.NativeStart.main(Native Method)
D/return ( 2002): null
D/AndroidRuntime( 2002): Shutting down VM
W/dalvikvm( 2002): threadid=1: thread exiting with uncaught exception (group=0x2aac4560)
E/AndroidRuntime( 2002): FATAL EXCEPTION: main
E/AndroidRuntime( 2002): java.lang.NullPointerException: uriString
E/AndroidRuntime( 2002): at android.net.Uri$StringUri.<init>(Uri.java:420)
E/AndroidRuntime( 2002): at android.net.Uri$StringUri.<init>(Uri.java:410)
E/AndroidRuntime( 2002): at android.net.Uri.parse(Uri.java:382)
//////The Changed Uri.getFile(); Line
E/AndroidRuntime( 2002): at com.MYAPP.Screenshots.onOptionsItemSelected(Screenshots.java:82)
E/AndroidRuntime( 2002): at android.support.v4.app.Watson.onMenuItemSelected(Watson.java:119)
E/AndroidRuntime( 2002): at com.actionbarsherlock.ActionBarSherlock.callbackOptionsItemSelected(ActionBarSherlock.java:603)
E/AndroidRuntime( 2002): at com.actionbarsherlock.internal.ActionBarSherlockCompat.onMenuItemSelected(ActionBarSherlockCompat.java:529)
E/AndroidRuntime( 2002): at com.actionbarsherlock.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:738)
E/AndroidRuntime( 2002): at com.actionbarsherlock.internal.view.menu.SubMenuBuilder.dispatchMenuItemSelected(SubMenuBuilder.java:83)
E/AndroidRuntime( 2002): at com.actionbarsherlock.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:148)
E/AndroidRuntime( 2002): at com.actionbarsherlock.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:879)
E/AndroidRuntime( 2002): at com.actionbarsherlock.internal.view.menu.MenuPopupHelper.onItemClick(MenuPopupHelper.java:158)
E/AndroidRuntime( 2002): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
E/AndroidRuntime( 2002): at android.widget.ListView.performItemClick(ListView.java:3513)
E/AndroidRuntime( 2002): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1812)
E/AndroidRuntime( 2002): at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime( 2002): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 2002): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 2002): at android.app.ActivityThread.main(ActivityThread.java:3822)
E/AndroidRuntime( 2002): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 2002): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 2002): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime( 2002): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime( 2002): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 181): Force finishing activity com.MYAPP/.Screenshots
W/WindowManager( 181)
Starting to think I should just dump the whole imageview thing.
i need to figure out if i can save to SD how I am doing, and ALSO save to a cache (and overwrite other ones, so only one image persists there)
Click to expand...
Click to collapse
Post your code. We cannot help you if you just say "I changed this line."
It is not getFile but fromFile.
HaHa I know, im not trying to throw puzzles out at people randomly.
But the errors in the log were from those new lines(in red)
the string path
and fromFile path ones
I may be getting somewhere with this though, i found a little section on stackoverflow that i hadn't seen in the other 30 questions about images or screenshots. :fingers-crossed:
Plus i glad I always have about 5 other projects on can work on when I get stuck.
out of ideas said:
HaHa I know, im not trying to throw puzzles out at people randomly.
But the errors in the log were from those new lines(in red)
the string path
and fromFile path ones
I may be getting somewhere with this though, i found a little section on stackoverflow that i hadn't seen in the other 30 questions about images or screenshots. :fingers-crossed:
Plus i glad I always have about 5 other projects on can work on when I get stuck.
Click to expand...
Click to collapse
The problem occurs in the saveBitmap method. For that reason the path is null and then a NPE is thrown. Check your code to save the bitmap.

[q] App force closes after adding admod SDK

Guys,I am trying to integrate admob SDK in my app from the past 3 hours and have no luck.
I have added the jar libraries ( build path), included in build paths, everything is good there.
main activity :
Code:
// Create the adView
adView = new AdView(this, AdSize.BANNER, MY_AD_UNIT_ID);
// Lookup your LinearLayout assuming it's been given
// the attribute android:id="@+id/mainLayout"
RelativeLayout layout = (RelativeLayout)findViewById(R.id.ad);
// Add the adView to it
layout.addView(adView);
// Initiate a generic request to load it with an ad
adView.loadAd(new AdRequest());
layout
Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<com.google.ads.AdView
android:id="@+id/ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
ads:adSize="BANNER"
ads:adUnitId="a15XZXXXXX3"
ads:loadAdOnCreate="true" />
everything loaded on the manifest file as well!
LOGCAT :
Code:
07-09 15:33:20.362: D/dalvikvm(12621): GC_CONCURRENT freed 188K, 3% free 8916K/9132K, paused 5ms+8ms, total 46ms
07-09 15:33:20.362: E/AndroidRuntime(12621): FATAL EXCEPTION: main
07-09 15:33:20.362: E/AndroidRuntime(12621): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.PACKAGE/com.PACKAGE.MainActivity}: java.lang.NullPointerException
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.os.Handler.dispatchMessage(Handler.java:99)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.os.Looper.loop(Looper.java:137)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-09 15:33:20.362: E/AndroidRuntime(12621): at java.lang.reflect.Method.invokeNative(Native Method)
07-09 15:33:20.362: E/AndroidRuntime(12621): at java.lang.reflect.Method.invoke(Method.java:511)
07-09 15:33:20.362: E/AndroidRuntime(12621): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-09 15:33:20.362: E/AndroidRuntime(12621): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-09 15:33:20.362: E/AndroidRuntime(12621): at dalvik.system.NativeStart.main(Native Method)
07-09 15:33:20.362: E/AndroidRuntime(12621): Caused by: java.lang.NullPointerException
07-09 15:33:20.362: E/AndroidRuntime(12621): at com.PACKAGE.MainActivity.onCreate(MainActivity.java:42)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.Activity.performCreate(Activity.java:5104)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
07-09 15:33:20.362: E/AndroidRuntime(12621): ... 11 more
07-09 15:33:22.877: I/Process(12621): Sending signal. PID: 12621 SIG: 9
chintz24 said:
Guys,I am trying to integrate admob SDK in my app from the past 3 hours and have no luck.
07-09 15:33:20.362: E/AndroidRuntime(12621): Caused by: java.lang.NullPointerException
07-09 15:33:20.362: E/AndroidRuntime(12621): at com.PACKAGE.MainActivity.onCreate(MainActivity.java:42)
Click to expand...
Click to collapse
says there, line 42, your asking "NULL" to do something! No idea what is on line 42, but would assume it's your ad view, so maybe your loading the wrong layout ? or even attempting to findViewById before setContentView() ? Would need more info/code
deanwray said:
says there, line 42, your asking "NULL" to do something! No idea what is on line 42, but would assume it's your ad view, so maybe your loading the wrong layout ? or even attempting to findViewById before setContentView() ? Would need more info/code
Click to expand...
Click to collapse
or even attempting to findViewById before setContentView()
This is what I was doing.
Thanks a lot.
Also does it take time to load ads?
because I dont see anything. Not even blank "ads by google"
chintz24 said:
or even attempting to findViewById before setContentView()
This is what I was doing.
Thanks a lot.
Also does it take time to load ads?
because I dont see anything. Not even blank "ads by google"
Click to expand...
Click to collapse
No idea, not used ads yet
Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<com.google.ads.AdView
android:id="@+id/ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
ads:adSize="BANNER"
ads:adUnitId="aXXXXXXXXXXX"
ads:loadAdOnCreate="true" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true" />
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:minHeight="1dip" />
</RelativeLayout>
This is my layout.xml
Thanks, its sorted, I didnt have any container for my ads. Done now
chintz24 said:
Guys,I am trying to integrate admob SDK in my app from the past 3 hours and have no luck.
I have added the jar libraries ( build path), included in build paths, everything is good there.
main activity :
Code:
// Create the adView
adView = new AdView(this, AdSize.BANNER, MY_AD_UNIT_ID);
// Lookup your LinearLayout assuming it's been given
// the attribute android:id="@+id/mainLayout"
RelativeLayout layout = (RelativeLayout)findViewById(R.id.ad);
// Add the adView to it
layout.addView(adView);
// Initiate a generic request to load it with an ad
adView.loadAd(new AdRequest());
layout
Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<com.google.ads.AdView
android:id="@+id/ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
ads:adSize="BANNER"
ads:adUnitId="a15XZXXXXX3"
ads:loadAdOnCreate="true" />
everything loaded on the manifest file as well!
LOGCAT :
Code:
07-09 15:33:20.362: D/dalvikvm(12621): GC_CONCURRENT freed 188K, 3% free 8916K/9132K, paused 5ms+8ms, total 46ms
07-09 15:33:20.362: E/AndroidRuntime(12621): FATAL EXCEPTION: main
07-09 15:33:20.362: E/AndroidRuntime(12621): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.PACKAGE/com.PACKAGE.MainActivity}: java.lang.NullPointerException
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.os.Handler.dispatchMessage(Handler.java:99)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.os.Looper.loop(Looper.java:137)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-09 15:33:20.362: E/AndroidRuntime(12621): at java.lang.reflect.Method.invokeNative(Native Method)
07-09 15:33:20.362: E/AndroidRuntime(12621): at java.lang.reflect.Method.invoke(Method.java:511)
07-09 15:33:20.362: E/AndroidRuntime(12621): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-09 15:33:20.362: E/AndroidRuntime(12621): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-09 15:33:20.362: E/AndroidRuntime(12621): at dalvik.system.NativeStart.main(Native Method)
07-09 15:33:20.362: E/AndroidRuntime(12621): Caused by: java.lang.NullPointerException
07-09 15:33:20.362: E/AndroidRuntime(12621): at com.PACKAGE.MainActivity.onCreate(MainActivity.java:42)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.Activity.performCreate(Activity.java:5104)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
07-09 15:33:20.362: E/AndroidRuntime(12621): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
07-09 15:33:20.362: E/AndroidRuntime(12621): ... 11 more
07-09 15:33:22.877: I/Process(12621): Sending signal. PID: 12621 SIG: 9
Click to expand...
Click to collapse
Hi,
You are mixing the two solutions for integration of admob banners (XML and code). The coding solution assumes that you have a layout that you want to populate with ads (useful when using different ad networks). In your case you define the admob banner in the XML so you don't need to call it at all in the code, If you think to set a listener (to do something when admob failed to show ads) in this case you can call and set your ad listener (that you implement on the activity) this way:
AdView adView = (AdView)findViewById(R.id.ad);
adView.setAdListener (this);
adView.loadAd(new AdRequest());
Hope this will help

Null Pointer Exception

Hello there,
I am trying to learn android application development through one of the online tutorials .I am stuck at a point and since,both java and android are new for me I can't figure out how to get out of it.Here's the code to my Startingpoint.java:
Code:
public class Startingpoint extends Activity {
int counter;
Button add,sub;
TextView display;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
counter=0;
add=(Button)findViewById(R.id.bAdd);
sub=(Button)findViewById(R.id.bSub);
display=(TextView)findViewById(R.id.display);
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
counter++;
display.setText("Your total is " + counter);
}
});
sub.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
counter--;
display.setText("Your total is" + counter);
}
});
}
}
The following are the contents within the LineaLlayout in my main.xml file:
Code:
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/result"
android:textSize="25sp"
android:layout_gravity="fill_horizontal"
android:gravity="center"
android:id="@+id/display"
/>
<Button
android:layout_width="250dp"
android:layout_height="wrap_content"
android:text="@string/bAdd"
android:layout_gravity="center"
android:gravity="center"
android:id="@+id/bAdd"
/>
<Button
android:layout_width="250dp"
android:layout_height="wrap_content"
android:text="@string/bSub"
android:layout_gravity="center"
android:gravity="center"
android:id="@+id/bSub"
/>
And this is what the logcat has to say :
Code:
02-13 11:44:12.076: D/AndroidRuntime(2026): Shutting down VM
02-13 11:44:12.076: W/dalvikvm(2026): threadid=1: thread exiting with uncaught exception (group=0xb2d5bb08)
02-13 11:44:12.156: E/AndroidRuntime(2026): FATAL EXCEPTION: main
02-13 11:44:12.156: E/AndroidRuntime(2026): Process: com.thenewboston.rohit, PID: 2026
02-13 11:44:12.156: E/AndroidRuntime(2026): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thenewboston.rohit/com.thenewboston.rohit.Startingpoint}: java.lang.NullPointerException
02-13 11:44:12.156: E/AndroidRuntime(2026): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
02-13 11:44:12.156: E/AndroidRuntime(2026): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
02-13 11:44:12.156: E/AndroidRuntime(2026): at android.app.ActivityThread.access$700(ActivityThread.java:135)
02-13 11:44:12.156: E/AndroidRuntime(2026): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
02-13 11:44:12.156: E/AndroidRuntime(2026): at android.os.Handler.dispatchMessage(Handler.java:102)
02-13 11:44:12.156: E/AndroidRuntime(2026): at android.os.Looper.loop(Looper.java:137)
02-13 11:44:12.156: E/AndroidRuntime(2026): at android.app.ActivityThread.main(ActivityThread.java:4998)
02-13 11:44:12.156: E/AndroidRuntime(2026): at java.lang.reflect.Method.invokeNative(Native Method)
02-13 11:44:12.156: E/AndroidRuntime(2026): at java.lang.reflect.Method.invoke(Method.java:515)
02-13 11:44:12.156: E/AndroidRuntime(2026): atcom.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
02-13 11:44:12.156: E/AndroidRuntime(2026): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
02-13 11:44:12.156: E/AndroidRuntime(2026): at dalvik.system.NativeStart.main(Native Method)
02-13 11:44:12.156: E/AndroidRuntime(2026): Caused by: java.lang.NullPointerException
02-13 11:44:12.156: E/AndroidRuntime(2026): at com.thenewboston.rohit.Startingpoint.onCreate(Startingpoint.java:21)
02-13 11:44:12.156: E/AndroidRuntime(2026): at android.app.Activity.performCreate(Activity.java:5243)
02-13 11:44:12.156: E/AndroidRuntime(2026): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
02-13 11:44:12.156: E/AndroidRuntime(2026): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
02-13 11:44:12.156: E/AndroidRuntime(2026): ... 11 more
Being inexperienced in java , I could not figure out what's wrong with the code.May be the exception is due to my add,sub and display being null but I am not sure.Please help me figure out what's wrong with my code and how to deal with it.
Any help is greatly appreciated.
Well, you can find the line where it crashes in the logcat:
Code:
02-13 11:44:12.156: E/AndroidRuntime(2026): Caused by: java.lang.NullPointerException
02-13 11:44:12.156: E/AndroidRuntime(2026): at com.thenewboston.rohit.Startingpoint.onCreate([B]Startingpoint.java:21[/B])
It's line 21. Which one is that?
Have a look at my debugging tutorial here as well, mainly the part on understanding the logcat. It will probably be very helpful and save much time: http://forum.xda-developers.com/showthread.php?t=2325164
nikwen said:
Well, you can find the line where it crashes in the logcat:
Code:
02-13 11:44:12.156: E/AndroidRuntime(2026): Caused by: java.lang.NullPointerException
02-13 11:44:12.156: E/AndroidRuntime(2026): at com.thenewboston.rohit.Startingpoint.onCreate([B]Startingpoint.java:21[/B])
It's line 21. Which one is that?
Have a look at my debugging tutorial here as well, mainly the part on understanding the logcat. It will probably be very helpful and save much time: http://forum.xda-developers.com/showthread.php?t=2325164
Click to expand...
Click to collapse
I bet they must be the findViewById(int id);
as much i trust my counting skills line 21 is calling for one the views
i still remeber the first NPE when i started android
Sent from my GT-S5302 using Tapatalk 2
I am sorry , I should have mentioned it.
Line 21 -> add.setOnClickListener(new View.OnClickListener()
DarkMethod said:
I am sorry , I should have mentioned it.
Line 21 -> add.setOnClickListener(new View.OnClickListener()
Click to expand...
Click to collapse
It means the.view with id bAdd was not found make sure have declared it in your layout
Sent from my GT-S5302 using Tapatalk 2
I have declared the ids for each view as you can see in the layout.xml attached.This NPE is turning out to be quite frustrating now.
DarkMethod said:
I have declared the ids for each view as you can see in the layout.xml attached.This NPE is turning out to be quite frustrating now.
Click to expand...
Click to collapse
do one thing
add a breakpoint to each line
then debug your app if on Eclipse or Android Studio !
and watch the control flow through each line this should narrow you down to the root cause.
Sent from my GT-S5302 using Tapatalk 2
sak-venom1997 said:
do one thing
add a breakpoint to each line
then debug your app if on Eclipse or Android Studio !
and watch the control flow through each line this should narrow you down to the root cause.
Sent from my GT-S5302 using Tapatalk 2
Click to expand...
Click to collapse
More on that here as well: http://forum.xda-developers.com/showthread.php?t=2325164
nikwen said:
More on that here as well: http://forum.xda-developers.com/showthread.php?t=2325164
Click to expand...
Click to collapse
indeed a great one :thumbup:
Sent from my GT-S5302 using Tapatalk 2
sak-venom1997 said:
indeed a great one :thumbup:
Sent from my GT-S5302 using Tapatalk 2
Click to expand...
Click to collapse
Thanks.

Android: Unfortunately the "app name" stopped! My first app

I've just started to build my first android app and this 1st time errors are bugging me now since 2 days. Finding no solution I had to come here. I have been following Androids official tutorial for my first app and can't open my app.
Error: "Unfortunately "app name" has stopped"
Here is my manisfest file,
Code:
<manifest xmlns:android=" [B]removed due to new member at the forum warning! 10 posts minimum need to post link:([/B]
package="app2.android"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity android:name="MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Log Cat
03-10 08:59:54.310: D/dalvikvm(1671): Not late-enabling CheckJNI (already on)
03-10 08:59:54.400: D/AndroidRuntime(1671): Shutting down VM
03-10 08:59:54.400: W/dalvikvm(1671): threadid=1: thread exiting with uncaught exception (group=0xb2d88b20)
03-10 08:59:54.400: E/AndroidRuntime(1671): FATAL EXCEPTION: main
03-10 08:59:54.400: E/AndroidRuntime(1671): Process: app2.android, PID: 1671
03-10 08:59:54.400: E/AndroidRuntime(1671): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{app2.android/app2.android.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "app2.android.MainActivity" on path: DexPathList[[zip file "/data/app/app2.android-1.apk"],nativeLibraryDirectories=[/data/app-lib/app2.android-1, /vendor/lib, /system/lib]]
03-10 08:59:54.400: E/AndroidRuntime(1671): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
03-10 08:59:54.400: E/AndroidRuntime(1671): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
03-10 08:59:54.400: E/AndroidRuntime(1671): at android.app.ActivityThread.access$800(ActivityThread.java:135)
03-10 08:59:54.400: E/AndroidRuntime(1671): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
03-10 08:59:54.400: E/AndroidRuntime(1671): at android.os.Handler.dispatchMessage(Handler.java:102)
03-10 08:59:54.400: E/AndroidRuntime(1671): at android.os.Looper.loop(Looper.java:136)
03-10 08:59:54.400: E/AndroidRuntime(1671): at android.app.ActivityThread.main(ActivityThread.java:5017)
03-10 08:59:54.400: E/AndroidRuntime(1671): at java.lang.reflect.Method.invokeNative(Native Method)
03-10 08:59:54.400: E/AndroidRuntime(1671): at java.lang.reflect.Method.invoke(Method.java:515)
03-10 08:59:54.400: E/AndroidRuntime(1671): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-10 08:59:54.400: E/AndroidRuntime(1671): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-10 08:59:54.400: E/AndroidRuntime(1671): at dalvik.system.NativeStart.main(Native Method)
03-10 08:59:54.400: E/AndroidRuntime(1671): Caused by: java.lang.ClassNotFoundException: Didn't find class "app2.android.MainActivity" on path: DexPathList[[zip file "/data/app/app2.android-1.apk"],nativeLibraryDirectories=[/data/app-lib/app2.android-1, /vendor/lib, /system/lib]]
03-10 08:59:54.400: E/AndroidRuntime(1671): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
03-10 08:59:54.400: E/AndroidRuntime(1671): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
03-10 08:59:54.400: E/AndroidRuntime(1671): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
03-10 08:59:54.400: E/AndroidRuntime(1671): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
03-10 08:59:54.400: E/AndroidRuntime(1671): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
03-10 08:59:54.400: E/AndroidRuntime(1671): ... 11 more
I have been rolling all over the internet for solutions, tried so many, doesn't work!!! PLEASE HELP!
Activity name change to
.MainActivity in manifest
Sent from my GT-S7392 using XDA Premium 4 mobile app
arpitkh96 said:
Activity name change to
.MainActivity in manifest
Sent from my GT-S7392 using XDA Premium 4 mobile app
Click to expand...
Click to collapse
i did. Same error!:crying:
Try writing the full package name to instead of just "MainActivity"
<activity android:name="app2.android.MainActivity" >
In the manifest change your activity name to <activity android:name="app2.android.MainActivity" > and also make sure that your project src folder has correct package inside (named app2.android)

LG QuickMemo for CM11

I'm trying to make QuickMemo work on CM... So far it's not going anywhere as I'm kinda noob with Android... And I'm hoping someone with more knowledge can help me!
I copied LGQMemo.apk to /system/priv-app and was able to run it through Secure settings Launch activity and here is what I got in return:
06-11 11:54:48.412 I/ActivityManager( 826): START u0 {flg=0x10000000 cmp=com.lge.QuickClip/.QuickClipActivity} from pid 8370
06-11 11:54:48.422 I/SecureSettings.ActionService( 8370): onHandleIntent::Action Success
06-11 11:54:48.422 V/Zygote ( 8527): Switching descriptor 42 to /dev/null
06-11 11:54:48.422 V/Zygote ( 8527): Switching descriptor 9 to /dev/null
06-11 11:54:48.422 I/ActivityManager( 826): Start proc com.lge.QuickClip for activity com.lge.QuickClip/.QuickClipActivity: pid=8527 uid=10149 gids={50149, 1028, 1015}
06-11 11:54:48.462 I/dalvikvm( 8527): DexOpt: mismatch dep name: '/data/dalvik-cache/[email protected]@[email protected]' vs. '/system/framework/core.odex'
06-11 11:54:48.462 E/dalvikvm( 8527): /system/priv-app/LGQMemo.apk odex has stale dependencies
06-11 11:54:48.462 D/ActivityThread( 8527): handleBindApplication:com.lge.QuickClip
06-11 11:54:48.462 D/ActivityThread( 8527): setTargetHeapUtilization:0.75
06-11 11:54:48.462 D/ActivityThread( 8527): setTargetHeapMinFree:2097152
06-11 11:54:48.462 W/dalvikvm( 8527): Unable to resolve superclass of Lcom/lge/QuickClip/QuickClipActivity; (270)
06-11 11:54:48.462 W/dalvikvm( 8527): Link of class 'Lcom/lge/QuickClip/QuickClipActivity;' failed
06-11 11:54:48.462 D/AndroidRuntime( 8527): Shutting down VM
06-11 11:54:48.462 W/dalvikvm( 8527): threadid=1: thread exiting with uncaught exception (group=0x419b2ce0)
06-11 11:54:48.472 E/AndroidRuntime( 8527): FATAL EXCEPTION: main
06-11 11:54:48.472 E/AndroidRuntime( 8527): Process: com.lge.QuickClip, PID: 8527
06-11 11:54:48.472 E/AndroidRuntime( 8527): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.lge.QuickClip/com.lge.QuickClip.QuickClipActivity}: java.lang.ClassNotFoundException: Didn't find class "com.lge.QuickClip.QuickClipActivity" on path: DexPathList[[zip file "/system/priv-app/LGQMemo.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
06-11 11:54:48.472 E/AndroidRuntime( 8527): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2120)
06-11 11:54:48.472 E/AndroidRuntime( 8527): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2253)
06-11 11:54:48.472 E/AndroidRuntime( 8527): at android.app.ActivityThread.access$800(ActivityThread.java:145)
06-11 11:54:48.472 E/AndroidRuntime( 8527): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1206)
06-11 11:54:48.472 E/AndroidRuntime( 8527): at android.os.Handler.dispatchMessage(Handler.java:102)
06-11 11:54:48.472 E/AndroidRuntime( 8527): at android.os.Looper.loop(Looper.java:136)
06-11 11:54:48.472 E/AndroidRuntime( 8527): at android.app.ActivityThread.main(ActivityThread.java:5128)
06-11 11:54:48.472 E/AndroidRuntime( 8527): at java.lang.reflect.Method.invokeNative(Native Method)
06-11 11:54:48.472 E/AndroidRuntime( 8527): at java.lang.reflect.Method.invoke(Method.java:515)
06-11 11:54:48.472 E/AndroidRuntime( 8527): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
06-11 11:54:48.472 E/AndroidRuntime( 8527): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:611)
06-11 11:54:48.472 E/AndroidRuntime( 8527): at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
06-11 11:54:48.472 E/AndroidRuntime( 8527): at dalvik.system.NativeStart.main(Native Method)
06-11 11:54:48.472 E/AndroidRuntime( 8527): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.lge.QuickClip.QuickClipActivity" on path: DexPathList[[zip file "/system/priv-app/LGQMemo.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
06-11 11:54:48.472 E/AndroidRuntime( 8527): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
06-11 11:54:48.472 E/AndroidRuntime( 8527): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
06-11 11:54:48.472 E/AndroidRuntime( 8527): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
06-11 11:54:48.472 E/AndroidRuntime( 8527): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
06-11 11:54:48.472 E/AndroidRuntime( 8527): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2111)
06-11 11:54:48.472 E/AndroidRuntime( 8527): ... 12 more
06-11 11:54:48.472 W/ActivityManager( 826): Force finishing activity com.lge.QuickClip/.QuickClipActivity
06-11 11:54:48.472 W/InputMethodManagerService( 826): Window already focused, ignoring focus gain of: [email protected] attribute=null, token = [email protected]
06-11 11:54:48.972 W/ActivityManager( 826): Activity pause timeout for ActivityRecord{424ae208 u0 com.lge.QuickClip/.QuickClipActivity t15 f}
06-11 11:54:49.022 I/Timeline( 1458): Timeline: Activity_idle id: [email protected] time:413509
06-11 11:54:49.482 D/qcom_sensors_hal( 826): hal_sensor1_data_cb: msg_type 2
06-11 11:54:49.922 I/Process ( 8527): Sending signal. PID: 8527 SIG: 9
06-11 11:54:49.932 D/PhoneStatusBar( 1239): disable: < expand icons alerts ticker system_info back home recent CLOCK* search >
06-11 11:54:49.932 W/InputMethodManagerService( 826): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$S[email protected] attribute=null, token = [email protected]
06-11 11:54:49.932 I/ActivityManager( 826): Process com.lge.QuickClip (pid 8527) has died.
Click to expand...
Click to collapse
Since I cannot install it directly, I was wondering why can the Secure Settings find the application and it's main activity but in the logcat it says it cannot be found?
Thanks in advance! (QMemo and QMemo.odex taken from latest CloudyFlex 2.4)
You may want to look for his people got the remote working. Pretty sure it looks for the eula being agreed to before it works
Sent from my LG-VS980 using Tapatalk
Hummm... But wouldn't it need to be shown on the EULA when you first start the system? As I recall, only the remote and VuTalk where shown...
I tried copying some files the the system/framework folder and got a reboot AND system format for free! Had to reinstall CM! Damn! (as I said I'm not a android/linux expert hehehe)

Categories

Resources