Using setPixels makes the app crash - Java for Android App Development

Hi everybody,
I'm new to android coding, so I'm just making same small tests with the API.
Right now I have a problem using setPixels, it makes my app crash when I use it.
Here is the beginning of the onCreate :
Code:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fullscreen);
ImageView image = (ImageView) findViewById(R.id.sly);
Bitmap bMap = BitmapFactory.decodeResource(getResources(), R.drawable.pic793849);
final int bMapWidth = bMap.getWidth();
final int bMapHeight = bMap.getHeight();
int[] pixels = new int[bMapHeight*bMapWidth];
bMap.getPixels(pixels, 0, bMapWidth, 0, 0, bMapWidth, bMapHeight);
for(int i=0 ; i<bMapHeight; i++)
{
for(int j=0 ; j<bMapWidth; j++)
{
//pixels[ i + (j*bMapHeight)] ^= 77;
}
}
bMap.setPixels(pixels, 0, bMapWidth, 0, 0, bMapWidth, bMapHeight);
// image.setImageBitmap(bMap);
final View controlsView = findViewById(R.id.fullscreen_content_controls);
final View contentView = findViewById(R.id.fullscreen_content);
If I comment the setPixels line, the app runs fine, if I uncomment it, it crashed right away.
I don't get what I'm doing wrong, the bMap is allocated, the pixels too, I'm not out of bounds... any help would be appreciated !
here is the logCat :
06-12 10:25:19.770: W/ActivityThread(1074): Application com.example.moos is waiting for the debugger on port 8100...
06-12 10:25:19.810: I/System.out(1074): Sending WAIT chunk
06-12 10:25:20.280: I/dalvikvm(1074): Debugger is active
06-12 10:25:20.470: I/System.out(1074): Debugger has connected
06-12 10:25:20.480: I/System.out(1074): waiting for debugger to settle...
06-12 10:25:20.690: I/System.out(1074): waiting for debugger to settle...
06-12 10:25:20.890: I/System.out(1074): waiting for debugger to settle...
06-12 10:25:21.090: I/System.out(1074): waiting for debugger to settle...
06-12 10:25:21.290: I/System.out(1074): waiting for debugger to settle...
06-12 10:25:21.500: I/System.out(1074): waiting for debugger to settle...
06-12 10:25:21.700: I/System.out(1074): waiting for debugger to settle...
06-12 10:25:21.900: I/System.out(1074): waiting for debugger to settle...
06-12 10:25:22.100: I/System.out(1074): debugger has settled (1363)
06-12 10:25:23.490: D/dalvikvm(1074): GC_FOR_ALLOC freed 37K, 4% free 3339K/3448K, paused 34ms, total 37ms
06-12 10:25:23.570: D/dalvikvm(1074): GC_FOR_ALLOC freed 36K, 4% free 3648K/3800K, paused 22ms, total 23ms
06-12 10:25:23.670: D/AndroidRuntime(1074): Shutting down VM
06-12 10:25:23.670: W/dalvikvm(1074): threadid=1: thread exiting with uncaught exception (group=0xb2aceba8)
06-12 10:25:23.760: E/AndroidRuntime(1074): FATAL EXCEPTION: main
06-12 10:25:23.760: E/AndroidRuntime(1074): Process: com.example.moos, PID: 1074
06-12 10:25:23.760: E/AndroidRuntime(1074): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.moos/com.example.moos.FullscreenActivity}: java.lang.IllegalStateException
06-12 10:25:23.760: E/AndroidRuntime(1074): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
06-12 10:25:23.760: E/AndroidRuntime(1074): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
06-12 10:25:23.760: E/AndroidRuntime(1074): at android.app.ActivityThread.access$800(ActivityThread.java:135)
06-12 10:25:23.760: E/AndroidRuntime(1074): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
06-12 10:25:23.760: E/AndroidRuntime(1074): at android.os.Handler.dispatchMessage(Handler.java:102)
06-12 10:25:23.760: E/AndroidRuntime(1074): at android.os.Looper.loop(Looper.java:136)
06-12 10:25:23.760: E/AndroidRuntime(1074): at android.app.ActivityThread.main(ActivityThread.java:5017)
06-12 10:25:23.760: E/AndroidRuntime(1074): at java.lang.reflect.Method.invokeNative(Native Method)
06-12 10:25:23.760: E/AndroidRuntime(1074): at java.lang.reflect.Method.invoke(Method.java:515)
06-12 10:25:23.760: E/AndroidRuntime(1074): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
06-12 10:25:23.760: E/AndroidRuntime(1074): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
06-12 10:25:23.760: E/AndroidRuntime(1074): at dalvik.system.NativeStart.main(Native Method)
06-12 10:25:23.760: E/AndroidRuntime(1074): Caused by: java.lang.IllegalStateException
06-12 10:25:23.760: E/AndroidRuntime(1074): at android.graphics.Bitmap.setPixels(Bitmap.java:1427)
06-12 10:25:23.760: E/AndroidRuntime(1074): at com.example.moos.FullscreenActivity.onCreate(FullscreenActivity.java:114)
06-12 10:25:23.760: E/AndroidRuntime(1074): at android.app.Activity.performCreate(Activity.java:5231)
06-12 10:25:23.760: E/AndroidRuntime(1074): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
06-12 10:25:23.760: E/AndroidRuntime(1074): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
06-12 10:25:23.760: E/AndroidRuntime(1074): ... 11 more
Thanks in avance...

Caused by: IllegalStateException. http://developer.android.com/reference/android/graphics/Bitmap.html#setPixel(int, int, int) says: setPixel throws ISE
if the bitmap is not mutable. Conclusion: you need to make the bitmap mutable
Gesendet von meinem SM-N9005 mit Tapatalk

Thank you very much, it works.
I added those lines :
Code:
BitmapFactory.Options options = new BitmapFactory.Options();
options.inMutable = true;
Bitmap bMap = BitmapFactory.decodeResource(getResources(), R.drawable.pic793849, options);

Related

Touchscreen Unresponsive - Logcat Inside

Hi all,
I've had my Magic since September and for the last few weeks it has intermittently been unresponsive to touch, the screen displays fine but it won't acknowledge any touch. In the last 2 days this has gotten a lot worse and now it barely works at all.
Any attempt to access the Contacts/Dialer throws up a Force close on process com.android.phone
Initially I thought this was a software problem but now I am not so sure. I have reverted back to the stock Vodafone AU rom that I backed up when I initially purchased and am getting ready to send back to HTC but thought I would ask on here as well.
Below is the logcat from a fresh reboot - Quite a few errors I think
Code:
E:\HTC Magic Tools\android-sdk-windows\tools>adb logcat -b main *:W
E/RIL Acoustic( 33): can't open /dev/htc-acoustic -1
E/HTC Acoustic( 35): Fail to open /system/etc/AudioPara_VODA-Australia.csv -1.
E/A2DP ( 35): bt_audio_service_open failed
E/A2dpAudioInterface( 35): a2dp_init failed err: -111
E/AudioFlinger( 35): mA2dpDisableCount is already zero
W/SurfaceFlinger( 58): couldn't grant gpu core to pid 58
E/GLLogger( 58): h/w accelerated eglGetDisplay() failed (EGL_SUCCESS)
W/HAL ( 58): load: module=/system/lib/hw/copybit.sapphire.so error=Cannot
find library
W/HAL ( 58): load: module=/system/lib/hw/copybit.sapphire.so error=Cannot
find library
W/HAL ( 58): load: module=/system/lib/hw/copybit.sapphire.so error=Cannot
find library
W/HAL ( 58): load: module=/system/lib/hw/copybit.sapphire.so error=Cannot
find library
W/HAL ( 58): load: module=/system/lib/hw/overlay.sapphire.so error=Cannot
find library
W/HAL ( 58): load: module=/system/lib/hw/overlay.sapphire.so error=Cannot
find library
W/HAL ( 58): load: module=/system/lib/hw/overlay.msm7k.so error=Cannot fin
d library
W/HAL ( 58): load: module=/system/lib/hw/overlay.default.so error=Cannot f
ind library
W/HAL ( 58): load: module=/system/lib/hw/lights.sapphire.so error=Cannot f
ind library
W/HAL ( 58): load: module=/system/lib/hw/lights.sapphire.so error=Cannot f
ind library
E/lights ( 58): write_int failed to open /sys/class/leds/keyboard-backlight/b
rightness
W/ResourceType( 58): No package identifier when getting value for resource num
ber 0x7f060001
W/ResourceType( 58): No package identifier when getting value for resource num
ber 0x7f030003
W/ResourceType( 58): No package identifier when getting value for resource num
ber 0x7f030000
W/ResourceType( 58): No package identifier when getting value for resource num
ber 0x7f03000c
W/ResourceType( 58): No package identifier when getting value for resource num
ber 0x7f030000
W/ResourceType( 58): No package identifier when getting value for resource num
ber 0x00000000
W/StatusBar( 58): Icon not found in <system>: 0
W/CheckinService( 58): No saved kernel log file
E/ApplicationContext( 58): Couldn't create directory for SharedPreferences fil
e shared_prefs/wallpaper-hints.xml
W/ActivityManager( 58): Unable to start service Intent { action=com.android.us
sd.IExtendedNetworkService }: not found
W/SurfaceFlinger( 58): executeScheduledBroadcasts() skipped, contention on the
client. We'll try again later...
W/AudioFlinger( 35): write blocked for 111 msecs
Thanks in advance for any assistance you can offer me, it would be really appreciated!!
Let me know if you need further info
Some further information
If I try to open Contacts using the trackball the Logcat expands to add the following: -
Code:
W/InputManagerService( 58): Window already focused, ignoring focus gain of: co
[email protected]
W/ResourceType( 95): Failure getting entry for 0x7f030005 (t=2 e=5) in package
0: 0xffffffb5
W/dalvikvm( 95): threadid=3: thread exiting with uncaught exception (group=0x4
000fe70)
E/AndroidRuntime( 95): Uncaught handler: thread main exiting due to uncaught e
xception
E/AndroidRuntime( 95): java.lang.RuntimeException: Unable to start activity Co
mponentInfo{com.android.contacts/com.android.contacts.DialtactsActivity}: androi
d.content.res.Resources$NotFoundException: Resource ID #0x7f030005
E/AndroidRuntime( 95): at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2268)
E/AndroidRuntime( 95): at android.app.ActivityThread.handleLaunchActivi
ty(ActivityThread.java:2284)
E/AndroidRuntime( 95): at android.app.ActivityThread.access$1800(Activi
tyThread.java:112)
E/AndroidRuntime( 95): at android.app.ActivityThread$H.handleMessage(Ac
tivityThread.java:1692)
E/AndroidRuntime( 95): at android.os.Handler.dispatchMessage(Handler.ja
va:99)
E/AndroidRuntime( 95): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 95): at android.app.ActivityThread.main(ActivityThrea
d.java:3948)
E/AndroidRuntime( 95): at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime( 95): at java.lang.reflect.Method.invoke(Method.java:5
21)
E/AndroidRuntime( 95): at com.android.internal.os.ZygoteInit$MethodAndA
rgsCaller.run(ZygoteInit.java:782)
E/AndroidRuntime( 95): at com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:540)
E/AndroidRuntime( 95): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 95): Caused by: android.content.res.Resources$NotFoundExcept
ion: Resource ID #0x7f030005
E/AndroidRuntime( 95): at android.content.res.Resources.getValue(Resour
ces.java:846)
E/AndroidRuntime( 95): at android.content.res.Resources.loadXmlResource
Parser(Resources.java:1796)
E/AndroidRuntime( 95): at android.content.res.Resources.getLayout(Resou
rces.java:685)
E/AndroidRuntime( 95): at android.view.LayoutInflater.inflate(LayoutInf
later.java:318)
E/AndroidRuntime( 95): at android.view.LayoutInflater.inflate(LayoutInf
later.java:276)
E/AndroidRuntime( 95): at com.android.internal.policy.impl.PhoneWindow.
setContentView(PhoneWindow.java:309)
E/AndroidRuntime( 95): at android.app.Activity.setContentView(Activity.
java:1626)
E/AndroidRuntime( 95): at com.android.contacts.DialtactsActivity.onCrea
te(DialtactsActivity.java:73)
E/AndroidRuntime( 95): at android.app.Instrumentation.callActivityOnCre
ate(Instrumentation.java:1123)
E/AndroidRuntime( 95): at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2231)
E/AndroidRuntime( 95): ... 11 more
W/ActivityManager( 58): Scheduling restart of crashed service com.google.andro
id.apps.gtalkservice/com.google.android.gtalkservice.service.GTalkService in 500
0ms
W/InputManagerService( 58): Got RemoteException sending setActive(false) notif
ication to pid 95 uid 10004

[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.

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo java.lang.Nu

I am just taking baby steps in learning Android programming..I am following some tutorials for that and while studying how to implement onKeyListener I am getting an error 'java.lang.RuntimeException: Unable to instantiate activity ComponentInfo java.lang.NullPointerException'. This error is leading to another error 'adt unfortunately app has stopped' while trying to run the app on my phone. Here is the logcat:
05-15 15:55:22.087: D/AndroidRuntime(20672): Shutting down VM
05-15 15:55:22.087: W/dalvikvm(20672): threadid=1: thread exiting with uncaught exception (group=0x41ea1ba8)
05-15 15:55:22.087: E/AndroidRuntime(20672): FATAL EXCEPTION: main
05-15 15:55:22.087: E/AndroidRuntime(20672): Process: com.example.keyboardlistener, PID: 20672
05-15 15:55:22.087: E/AndroidRuntime(20672): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.keyboardlistener/com.example.keyboardlistener.MainActivity}: java.lang.NullPointerException
05-15 15:55:22.087: E/AndroidRuntime(20672): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
05-15 15:55:22.087: E/AndroidRuntime(20672): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
05-15 15:55:22.087: E/AndroidRuntime(20672): at android.app.ActivityThread.access$800(ActivityThread.java:135)
05-15 15:55:22.087: E/AndroidRuntime(20672): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
05-15 15:55:22.087: E/AndroidRuntime(20672): at android.os.Handler.dispatchMessage(Handler.java:102)
05-15 15:55:22.087: E/AndroidRuntime(20672): at android.os.Looper.loop(Looper.java:136)
05-15 15:55:22.087: E/AndroidRuntime(20672): at android.app.ActivityThread.main(ActivityThread.java:5017)
05-15 15:55:22.087: E/AndroidRuntime(20672): at java.lang.reflect.Method.invokeNative(Native Method)
05-15 15:55:22.087: E/AndroidRuntime(20672): at java.lang.reflect.Method.invoke(Method.java:515)
05-15 15:55:22.087: E/AndroidRuntime(20672): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
05-15 15:55:22.087: E/AndroidRuntime(20672): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
05-15 15:55:22.087: E/AndroidRuntime(20672): at dalvik.system.NativeStart.main(Native Method)
05-15 15:55:22.087: E/AndroidRuntime(20672): Caused by: java.lang.NullPointerException
05-15 15:55:22.087: E/AndroidRuntime(20672): at android.app.Activity.findViewById(Activity.java:1884)
05-15 15:55:22.087: E/AndroidRuntime(20672): at com.example.keyboardlistener.MainActivity.<init>(MainActivity.java:18)
05-15 15:55:22.087: E/AndroidRuntime(20672): at java.lang.Class.newInstanceImpl(Native Method)
05-15 15:55:22.087: E/AndroidRuntime(20672): at java.lang.Class.newInstance(Class.java:1208)
05-15 15:55:22.087: E/AndroidRuntime(20672): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
05-15 15:55:22.087: E/AndroidRuntime(20672): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
05-15 15:55:22.087: E/AndroidRuntime(20672): ... 11 more
05-15 16:00:21.837: I/dalvikvm(22483): Debugger is active
05-15 16:00:21.847: I/System.out(22483): Debugger has connected
05-15 16:00:21.857: I/System.out(22483): waiting for debugger to settle...
05-15 16:00:22.057: I/System.out(22483): waiting for debugger to settle...
05-15 16:00:22.257: I/System.out(22483): waiting for debugger to settle...
05-15 16:00:22.457: I/System.out(22483): waiting for debugger to settle...
05-15 16:00:22.657: I/System.out(22483): waiting for debugger to settle...
05-15 16:00:22.857: I/System.out(22483): waiting for debugger to settle...
05-15 16:00:23.057: I/System.out(22483): waiting for debugger to settle...
05-15 16:00:23.257: I/System.out(22483): waiting for debugger to settle...
05-15 16:00:23.457: I/System.out(22483): debugger has settled (1495)
05-15 16:00:23.797: D/dalvikvm(22483): threadid=1: still suspended after undo (sc=1 dc=1)
05-15 16:09:43.367: D/AndroidRuntime(24025): Shutting down VM
05-15 16:09:43.367: W/dalvikvm(24025): threadid=1: thread exiting with uncaught exception (group=0x41ea1ba8)
05-15 16:09:43.367: E/AndroidRuntime(24025): FATAL EXCEPTION: main
05-15 16:09:43.367: E/AndroidRuntime(24025): Process: com.example.keyboardlistener, PID: 24025
05-15 16:09:43.367: E/AndroidRuntime(24025): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.keyboardlistener/com.example.keyboardlistener.MainActivity}: java.lang.NullPointerException
05-15 16:09:43.367: E/AndroidRuntime(24025): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
05-15 16:09:43.367: E/AndroidRuntime(24025): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
05-15 16:09:43.367: E/AndroidRuntime(24025): at android.app.ActivityThread.access$800(ActivityThread.java:135)
05-15 16:09:43.367: E/AndroidRuntime(24025): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
05-15 16:09:43.367: E/AndroidRuntime(24025): at android.os.Handler.dispatchMessage(Handler.java:102)
05-15 16:09:43.367: E/AndroidRuntime(24025): at android.os.Looper.loop(Looper.java:136)
05-15 16:09:43.367: E/AndroidRuntime(24025): at android.app.ActivityThread.main(ActivityThread.java:5017)
05-15 16:09:43.367: E/AndroidRuntime(24025): at java.lang.reflect.Method.invokeNative(Native Method)
05-15 16:09:43.367: E/AndroidRuntime(24025): at java.lang.reflect.Method.invoke(Method.java:515)
05-15 16:09:43.367: E/AndroidRuntime(24025): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
05-15 16:09:43.367: E/AndroidRuntime(24025): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
05-15 16:09:43.367: E/AndroidRuntime(24025): at dalvik.system.NativeStart.main(Native Method)
05-15 16:09:43.367: E/AndroidRuntime(24025): Caused by: java.lang.NullPointerException
05-15 16:09:43.367: E/AndroidRuntime(24025): at com.example.keyboardlistener.MainActivity.onCreate(MainActivity.java:35)
05-15 16:09:43.367: E/AndroidRuntime(24025): at android.app.Activity.performCreate(Activity.java:5231)
05-15 16:09:43.367: E/AndroidRuntime(24025): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
05-15 16:09:43.367: E/AndroidRuntime(24025): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
05-15 16:09:43.367: E/AndroidRuntime(24025): ... 11 more
And here is the onCreate method:
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment())
.commit();
}
final EditText ed = (EditText)findViewById(R.id.editTextUserEntry1);
final TextView tv = (TextView)findViewById(R.id.TextResults);
ed.setOnKeyListener(new OnKeyListener(){
@override
public boolean onKey(View v, int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if(event.getAction()==KeyEvent.ACTION_DOWN)
{
if(keyCode == KeyEvent.KEYCODE_ENTER)
{
tv.setText(ed.getText());
}
}
return false;
}
});
}
Hi,
to understand the logs, please read this guide on debugging apps. It tells you all you need to know to find your bug. (In this case, have a look at line 35, probably one of the IDs you pass to findViewById does not match the one you have your view set to in the XML layout file)
Declare tv and ed as fields and then this should work. The problem is, i think, that you only declared them temporarily inside onCreate, which doesn't let them being used in another method
---------------------------------
Phone : Nexus 4
OS:
Pure KitKat 4.4.2 stock, no root, no mods
---------------------------------
4d 61 73 72 65 70 75 73 20 66 74 77
Gesendet von Tapatalk
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.krishn
package com.example.krishnaupaharaa;
import java.util.ArrayList;
import beanClass.Bfs;
import beanClass.ItemVO;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
public class CategoryList extends Activity {
ItemVO details;
Bfs categoryDetails;
ArrayList<ItemVO> itemList;
ArrayAdapter<String> arrayAdapter;
ListView lv;
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list_item_name);
itemList = new ArrayList<ItemVO>();
details = (ItemVO) ApplicationCache.getInstance().getValue("categoryDetails");
categoryDetails = (Bfs) ApplicationCache.getInstance().getValue("customerNameDetails");
//Log.d("TestTag", "Website address"+details.getMerchantWebsite());
//itemList = (ArrayList<ItemVO>) ApplicationCache.getInstance().getValue("customerNameDetails");
itemList = categoryDetails.getCategoryNameDetails();
//final LinkedHashMap<String,MFunctionVO> map = details.getMerchantFunctionalities();
lv = (ListView) findViewById(R.id.list1);
//String name = null;
arrayAdapter = new ArrayAdapter<String>(this,R.layout.listview_items,R.id.textView);
//arrayAdapter.add(details.getMerchantName());
//for(String s: map.keySet()){
// arrayAdapter.add(s);
//}
for (ItemVO mnvo : categoryDetails.getCategoryNameDetails())
{
Log.d("TestTag", "Name of custome care"+mnvo.getCategoryName());
arrayAdapter.add(mnvo.getCategoryName());
}
//lv.setAdapter(arrayAdapter);
lv.setAdapter(new MyAdapter(CategoryList.this,R.id.textView,itemList));
//Log.d("TestTag", "Values in details:" +details.getMerchantName());
//Log.d("TestTag", "Name in MerchantType class"+name);
lv.setOnItemClickListener(new OnItemClickListener() {
@override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
ApplicationCache.getInstance().setValue("merchantSpecificDetails", itemList.get(position));
Intent merchantIntent = new Intent(CategoryList.this,MyCart.class);
startActivity(merchantIntent);
}
});
}
private class MyAdapter extends ArrayAdapter<ItemVO>
{
private Context context;
private ArrayList<ItemVO> list;
public MyAdapter (Context context, int textViewResourceId, ArrayList<ItemVO> list)
{
super(context, textViewResourceId, list);
this.context = context;
this.list = list;
}
@override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
//return super.getView(position, convertView, parent);
{
LayoutInflater li = (LayoutInflater) getSystemService(context.LAYOUT_INFLATER_SERVICE);
convertView = li.inflate(R.layout.listview_items,null);
ImageView image=(ImageView) convertView.findViewById(R.id.imageView);
TextView itemName = (TextView) convertView.findViewById(R.id.textView);
String uri = "C:/Users/Deepak/workspace/KrishnaUpaharaa/res/drawable-hdpi" + list.get(position).getItemphoto();
Uri imguri = Uri.parse(uri);
Log.d("TestTag", "Inside getView"+list.get(position).getItemdescription());
image.setImageURI(imguri);
itemName.setText(list.get(position).getItemdescription());
return convertView;
}
}
}
}
Masrepus said:
Declare tv and ed as fields and then this should work. The problem is, i think, that you only declared them temporarily inside onCreate, which doesn't let them being used in another method
Click to expand...
Click to collapse
It not the problem. Both fields are final, so the values are copied to the instance of anonymous inner class via auto-generated constructor, thus both fields can be used inside of the instance of inner class.

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)

What mechanism periodically restores the Amazon stock apps on FireOS6?

I guess I am in the minority here in that I do not mind having an Amazon tablet, but I would still like some control over the apps that are on my device. To that end, I have user-disabled most of the stock frontend apps that come with FireOS 6.3.0.1. This works well, even for the launcher. As a plus, if I come across an app that I disabled but now want to have on my tablet, I can reenable it right from the Play Store page.
The issue is that periodically, some of the stock apps get restored. This seems to happen for me at 1:57am every other night when the device is not in use. Most annoying is that the Fire Launcher is restored (hard -- a fresh apk seems to be actually copied and installed). Another app that commonly reappears is the Amazon Music app.
Now, if you properly nuke all Amazon apps from the device, as per the various threads here, this does not happen. So there must be something among the various Amazon bloatware that does this periodic reset. I wonder if anyone knows what exactly that is, so I can disable it.
Here is a logcat from last night showing the reset happening:
Code:
06-12 01:57:17.938 1330 6701 I chatty : uid=1000(system) com.amazon.knight.ecs expire 1 line
06-12 01:57:19.554 6371 6394 I FrameworkJumpTable: Successfully loaded all classes
06-12 01:57:19.585 6371 6394 I FrameworkJumpTable: Successfully loaded all methods
06-12 01:57:19.612 6371 6394 I FrameworkJumpTable: Successfully loaded all fields
06-12 01:57:19.612 6371 6394 I FrameworkJumpTable: Successfully loaded all constructors
06-12 01:57:19.705 6746 6746 I FrameworkJumpTable: Successfully loaded all classes
06-12 01:57:19.728 6746 6746 I FrameworkJumpTable: Successfully loaded all methods
06-12 01:57:19.730 6746 6746 I FrameworkJumpTable: Successfully loaded all fields
06-12 01:57:19.730 6746 6746 I FrameworkJumpTable: Successfully loaded all constructors
06-12 01:57:20.445 6787 6845 I FrameworkJumpTable: Successfully loaded all classes
06-12 01:57:20.462 6787 6845 I FrameworkJumpTable: Successfully loaded all methods
06-12 01:57:20.464 6787 6845 I FrameworkJumpTable: Successfully loaded all fields
06-12 01:57:20.471 6787 6845 I FrameworkJumpTable: Successfully loaded all constructors
06-12 01:57:21.479 575 1505 I chatty : uid=1000(system) Binder:575_11 expire 10 lines
06-12 01:57:22.544 575 588 I chatty : uid=1000(system) ActivityManager expire 10 lines
06-12 01:57:24.526 6371 6394 W PackageParser: Ignoring duplicate uses-permissions/uses-permissions-sdk-m: amazon.permission.SHARED_STORAGE_WRITE in package: com.amazon.firelauncher at: Binary XML file line #175
06-12 01:57:24.533 6371 6394 W SystemConfig: No directory /system/etc/sysconfig, skipping
06-12 01:57:24.652 6371 6394 W PackageParser: Ignoring duplicate uses-permissions/uses-permissions-sdk-m: com.amazon.identity.permission.GENERIC_IPC in package: com.amazon.firelauncher at: Binary XML file line #268
06-12 01:57:26.344 6962 6985 D DefContainer: Copying /cache/FireLauncher5-release.apk to base.apk
06-12 01:57:30.229 7004 7004 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.bindService:1450 android.content.ContextWrapper.bindService:636 com.amazon.client.metrics.MetricsServiceConnection.getService:72 com.amazon.client.metrics.MetricsServiceWrapper.getBoundService:46 com.amazon.client.metrics.MetricsServiceWrapper.<init>:37
06-12 01:57:33.226 575 2294 I chatty : uid=1000(system) Binder:575_17 expire 10 lines
06-12 01:57:33.999 7078 7078 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.startService:1386 android.content.ContextWrapper.startService:613 android.content.ContextWrapper.startService:613 com.android.keychain.KeyChainBroadcastReceiver.onReceive:12 android.app.ActivityThread.handleReceiver:3062
06-12 01:57:38.466 575 1302 I chatty : uid=1000(system) Binder:575_8 expire 10 lines
06-12 01:57:44.582 575 8760 I chatty : uid=1000(system) Binder:575_19 expire 10 lines
06-12 01:57:48.963 7519 7519 I FrameworkJumpTable: Successfully loaded all classes
06-12 01:57:48.987 7519 7519 I FrameworkJumpTable: Successfully loaded all methods
06-12 01:57:49.003 7519 7519 I FrameworkJumpTable: Successfully loaded all fields
06-12 01:57:49.003 7519 7519 I FrameworkJumpTable: Successfully loaded all constructors
06-12 01:57:50.931 7572 7572 I FrameworkJumpTable: Successfully loaded all classes
06-12 01:57:50.951 7572 7572 I FrameworkJumpTable: Successfully loaded all methods
06-12 01:57:50.953 7572 7572 I FrameworkJumpTable: Successfully loaded all fields
06-12 01:57:50.953 7572 7572 I FrameworkJumpTable: Successfully loaded all constructors

Categories

Resources