I have the following ImageView:
imageView.setBackgroundResource(R.drawable.create_user);
My create_user drawable looks like this:
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false">
<item android:drawable="#drawable/create_user_0" android:duration="500" />
<item android:drawable="#drawable/create_user_1" android:duration="500" />
</animation-list>
But when the .xml is being set in imageView.setBacgroundResource(R.drawable.create_user), it launches the following exception:
02-04 10:49:07.994: E/AndroidRuntime(1379): FATAL EXCEPTION: main
02-04 10:49:07.994: E/AndroidRuntime(1379): java.lang.OutOfMemoryError
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:596)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:832)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.content.res.Resources.loadDrawable(Resources.java:2988)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.content.res.Resources.getDrawable(Resources.java:1558)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.graphics.drawable.AnimationDrawable.inflate(AnimationDrawable.java:282)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:937)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:873)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.content.res.Resources.loadDrawable(Resources.java:2970)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.content.res.Resources.getDrawable(Resources.java:1558)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.view.View.setBackgroundResource(View.java:15697)
02-04 10:49:07.994: E/AndroidRuntime(1379): at com.facephi.sdk.ui.FragmentCreatingStructure.onCreateView(FragmentCreatingStructu re.java:29)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.app.Fragment.performCreateView(Fragment.java:1699)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:903)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1075)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.app.BackStackRecord.run(BackStackRecord.java:682)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1455)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.app.FragmentManagerImpl$1.run(FragmentManager.java:441)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.os.Handler.handleCallback(Handler.java:730)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.os.Handler.dispatchMessage(Handler.java:92)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.os.Looper.loop(Looper.java:176)
02-04 10:49:07.994: E/AndroidRuntime(1379): at android.app.ActivityThread.main(ActivityThread.java:5419)
02-04 10:49:07.994: E/AndroidRuntime(1379): at java.lang.reflect.Method.invokeNative(Native Method)
02-04 10:49:07.994: E/AndroidRuntime(1379): at java.lang.reflect.Method.invoke(Method.java:525)
02-04 10:49:07.994: E/AndroidRuntime(1379): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
02-04 10:49:07.994: E/AndroidRuntime(1379): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
02-04 10:49:07.994: E/AndroidRuntime(1379): at dalvik.system.NativeStart.main(Native Method)
I have to say that I've been using this animation for a looong time. And yesterday was the first time it started crashing.
I can't imagine what's going on at this point... Can anyone help me find what I'm doing wrong?
NOTE: It says Out of memory on a 638416-byte allocation before the mistake is launched.
NOTE2: It also says this several times before the application crashes.
02-04 11:23:56.179: I/dalvikvm(7266): "Binder_1" prio=5 tid=9 RUNNABLE
02-04 11:23:56.179: I/dalvikvm(7266): | group="main" sCount=0 dsCount=0 obj=0x427f2200 self=0x4192fcd0
02-04 11:23:56.179: I/dalvikvm(7266): | sysTid=7277 nice=0 sched=0/0 cgrp=apps handle=1100151432
02-04 11:23:56.179: I/dalvikvm(7266): | state=R schedstat=( 504400204 75428596 671 ) utm=34 stm=15 core=2
02-04 11:23:56.179: I/dalvikvm(7266): at dalvik.system.NativeStart.run(Native Method)
02-04 11:23:56.179: E/Camera-JNI(7266): Couldn't allocate byte array for JPEG data
02-04 11:23:56.239: I/dalvikvm-heap(7266): Clamp target GC heap from 71.012MB to 64.000MB
02-04 11:23:56.239: D/dalvikvm(7266): threadid=1: still suspended after undo (sc=1 dc=1)
02-04 11:23:56.239: D/dalvikvm(7266): GC_FOR_ALLOC freed 21K, 3% free 63352K/65192K, paused 17ms, total 17ms
02-04 11:23:56.239: I/dalvikvm-heap(7266): Forcing collection of SoftReferences for 460816-byte allocation
02-04 11:23:56.259: I/dalvikvm-heap(7266): Clamp target GC heap from 71.012MB to 64.000MB
02-04 11:23:56.259: D/dalvikvm(7266): threadid=1: still suspended after undo (sc=1 dc=1)
02-04 11:23:56.259: D/dalvikvm(7266): GC_BEFORE_OOM freed 0K, 3% free 63352K/65192K, paused 20ms, total 20ms
02-04 11:23:56.259: E/dalvikvm-heap(7266): Out of memory on a 460816-byte allocation.
Try adding android:largeHeap="true", in the manifest to see if this solves it.
Or Use api inSampleSize of bitmapfactory to sample the images.
I also faced this kind of error once but when I re sized my images it got resolved.
Try to re-size your images.
You can try to resize your images to adapt them to the exact size of the view, as explained here. You can even try using libraries like universal image loader which make this task easier.
Related
I'm working on an app which reads a .txt file that is stored in the SD card (inside /data/local). The problem I have is that it seems that it can access to the file path, but it can't access the file itself (although it has read and write permissions), it throws a FileNotFoundException.
Here I leave you the code and the log:
String ruta="/data/local/textojson.txt";
System.out.println(ruta);
String cadena="", Jsontx="";
File sd = Environment.getExternalStorageDirectory();
File f = new File(sd.getAbsolutePath(), ruta);
System.out.println(f);
BufferedReader entrada;
try
{
entrada = new BufferedReader(new FileReader(f));
System.out.println(entrada);
try
{
while((cadena=entrada.readLine())!=null)
{
Jsontx=cadena;
}
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FileNotFoundException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
I've added the READ_EXTERNAL_STORAGE permissions to the manifest, and the file really exists in that directory.
02-04 19:26:40.535: E/Trace(20167): error opening trace file: No such file or directory (2)
02-04 19:26:41.055: I/System.out(20167): /data/local/textojson.txt
02-04 19:26:41.066: I/System.out(20167): /mnt/sdcard/data/local/textojson.txt
02-04 19:26:41.066: W/System.err(20167): java.io.FileNotFoundException: /mnt/sdcard/data/local/textojson.txt: open failed: ENOENT (No such file or directory)
02-04 19:26:41.066: W/System.err(20167): at libcore.io.IoBridge.open(IoBridge.java:416)
02-04 19:26:41.075: W/System.err(20167): at java.io.FileInputStream.<init>(FileInputStream.java:78)
02-04 19:26:41.075: W/System.err(20167): at java.io.FileReader.<init>(FileReader.java:42)
02-04 19:26:41.075: W/System.err(20167): at es.example.jsonarchivo.Adapter.<init>(Adapter.java:47)
02-04 19:26:41.075: W/System.err(20167): at es.example.jsonarchivo.MainActivity.onCreate(MainActivity.java:27)
02-04 19:26:41.075: W/System.err(20167): at android.app.Activity.performCreate(Activity.java:5008)
02-04 19:26:41.085: W/System.err(20167): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
02-04 19:26:41.085: W/System.err(20167): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
02-04 19:26:41.085: W/System.err(20167): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
02-04 19:26:41.085: W/System.err(20167): at android.app.ActivityThread.access$600(ActivityThread.java:130)
02-04 19:26:41.085: W/System.err(20167): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
02-04 19:26:41.085: W/System.err(20167): at android.os.Handler.dispatchMessage(Handler.java:99)
02-04 19:26:41.085: W/System.err(20167): at android.os.Looper.loop(Looper.java:137)
02-04 19:26:41.085: W/System.err(20167): at android.app.ActivityThread.main(ActivityThread.java:4745)
02-04 19:26:41.095: W/System.err(20167): at java.lang.reflect.Method.invokeNative(Native Method)
02-04 19:26:41.105: W/System.err(20167): at java.lang.reflect.Method.invoke(Method.java:511)
02-04 19:26:41.105: W/System.err(20167): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
02-04 19:26:41.105: W/System.err(20167): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
02-04 19:26:41.105: W/System.err(20167): at dalvik.system.NativeStart.main(Native Method)
02-04 19:26:41.105: W/System.err(20167): Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
02-04 19:26:41.116: W/System.err(20167): at libcore.io.Posix.open(Native Method)
02-04 19:26:41.116: W/System.err(20167): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
02-04 19:26:41.116: W/System.err(20167): at libcore.io.IoBridge.open(IoBridge.java:400)
02-04 19:26:41.125: W/System.err(20167): ... 18 more
02-04 19:26:41.125: D/AndroidRuntime(20167): Shutting down VM
02-04 19:26:41.125: W/dalvikvm(20167): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
02-04 19:26:41.145: E/AndroidRuntime(20167): FATAL EXCEPTION: main
02-04 19:26:41.145: E/AndroidRuntime(20167): java.lang.RuntimeException: Unable to start activity ComponentInfo{es.example.jsonarchivo/es.example.jsonarchivo.MainActivity}: java.lang.NullPointerException
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.app.ActivityThread.access$600(ActivityThread.java:130)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.os.Handler.dispatchMessage(Handler.java:99)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.os.Looper.loop(Looper.java:137)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.app.ActivityThread.main(ActivityThread.java:4745)
02-04 19:26:41.145: E/AndroidRuntime(20167): at java.lang.reflect.Method.invokeNative(Native Method)
02-04 19:26:41.145: E/AndroidRuntime(20167): at java.lang.reflect.Method.invoke(Method.java:511)
02-04 19:26:41.145: E/AndroidRuntime(20167): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
02-04 19:26:41.145: E/AndroidRuntime(20167): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
02-04 19:26:41.145: E/AndroidRuntime(20167): at dalvik.system.NativeStart.main(Native Method)
02-04 19:26:41.145: E/AndroidRuntime(20167): Caused by: java.lang.NullPointerException
02-04 19:26:41.145: E/AndroidRuntime(20167): at com.android.internal.os.LoggingPrintStream.println(LoggingPrintStream.java:298)
02-04 19:26:41.145: E/AndroidRuntime(20167): at es.example.jsonarchivo.Adapter.<init>(Adapter.java:70)
02-04 19:26:41.145: E/AndroidRuntime(20167): at es.example.jsonarchivo.MainActivity.onCreate(MainActivity.java:27)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.app.Activity.performCreate(Activity.java:5008)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
02-04 19:26:41.145: E/AndroidRuntime(20167): ... 11 more
02-04 19:31:41.224: I/Process(20167): Sending signal. PID: 20167 SIG: 9
I hope I have explained it well, my mother tongue isn't english.
To recap in an answer,
java.io.FileNotFoundException: /mnt/sdcard/data/local/textojson.txt: open failed: ENOENT (No such file or directory)
means that the file does not exist. This can be verified with f.exists()
If the problem was permissions you should get open failed: EACCES (Permission denied)
I have a Error inflating class error that seemed to be caused by Bitmap (more details here: Android: Memory error because of an ImageView?) but when I comment the bitmap I still have the error while when I comment the Imageview5, no error. All the posts on stackoverflow about this error did not help solving my problem
02-04 10:03:04.353: E/AndroidRuntime(17427): FATAL EXCEPTION: main
02-04 10:03:04.353: E/AndroidRuntime(17427): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.kersplatt/com.example.kersplatt.ShareActivity}: android.view.InflateException: Binary XML file line #23: Error inflating class <unknown>
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.os.Handler.dispatchMessage(Handler.java:99)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.os.Looper.loop(Looper.java:130)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.app.ActivityThread.main(ActivityThread.java:3683)
02-04 10:03:04.353: E/AndroidRuntime(17427): at java.lang.reflect.Method.invokeNative(Native Method)
02-04 10:03:04.353: E/AndroidRuntime(17427): at java.lang.reflect.Method.invoke(Method.java:507)
02-04 10:03:04.353: E/AndroidRuntime(17427): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:875)
02-04 10:03:04.353: E/AndroidRuntime(17427): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:633)
02-04 10:03:04.353: E/AndroidRuntime(17427): at dalvik.system.NativeStart.main(Native Method)
02-04 10:03:04.353: E/AndroidRuntime(17427): Caused by: android.view.InflateException: Binary XML file line #23: Error inflating class <unknown>
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
02-04 10:03:04.353: E/AndroidRuntime(17427): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
02-04 10:03:04.353: E/AndroidRuntime(17427): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:209)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.app.Activity.setContentView(Activity.java:1657)
02-04 10:03:04.353: E/AndroidRuntime(17427): at com.example.kersplatt.ShareActivity.onCreate(ShareActivity.java:64)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
02-04 10:03:04.353: E/AndroidRuntime(17427): ... 11 more
02-04 10:03:04.353: E/AndroidRuntime(17427): Caused by: java.lang.reflect.InvocationTargetException
02-04 10:03:04.353: E/AndroidRuntime(17427): at java.lang.reflect.Constructor.constructNative(Native Method)
02-04 10:03:04.353: E/AndroidRuntime(17427): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
02-04 10:03:04.353: E/AndroidRuntime(17427): ... 23 more
02-04 10:03:04.353: E/AndroidRuntime(17427): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.content.res.Resources.loadDrawable(Resources.java:1709)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.widget.ImageView.<init>(ImageView.java:118)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.widget.ImageView.<init>(ImageView.java:108)
02-04 10:03:04.353: E/AndroidRuntime(17427): ... 26 more
and my line 23 is imageview5
<ImageView
android:id="#+id/imageView5"
android:layout_width="85dp"
android:layout_height="100dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="20dp"
android:adjustViewBounds="true"
android:src="#drawable/diviseur" />
It's a pretty misleading error, but it's caused by a nested exception, because the VM has run out of memory for the drawable diviseur. See the end of the stack trace:
02-04 10:03:04.353: E/AndroidRuntime(17427): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.content.res.Resources.loadDrawable(Resources.java:1709)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.widget.ImageView.<init>(ImageView.java:118)
02-04 10:03:04.353: E/AndroidRuntime(17427): at android.widget.ImageView.<init>(ImageView.java:108)
02-04 10:03:04.353: E/AndroidRuntime(17427): ... 26 more
Sometimes this may happen, the best practice is to create a scaled bitmap using the bitmap factory,
Bitmap result = Bitmap.createScaledBitmap(bitmapPicture,
imageWidth, imageHeight, false);
Try this and see if it helps
Also use,
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inPurgeable = true; // Tell to garbage collector that whether it needs free memory, the Bitmap can be cleared
opts.inTempStorage = new byte[32 * 1024];
and always recycle your bitmap when you leave that activity as it helps in freeing memory.
Hope this helps
I got the same error. My problem was that every phone loaded a 2k image as background of the activity. I solved the problem by scaling down this background image to 800x480 and 1280x720. Then I put this images into the ldpi, mdpi, ... folders.Now it works
I declare my activity in manifest file but it shows exception for me
<activity android:name="BuyClick"></activity>
I did not get what is happening to my manifest file
Exception are as follow
02-04 12:33:52.161: E/AndroidRuntime(1260): FATAL EXCEPTION: main
02-04 12:33:52.161: E/AndroidRuntime(1260): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.kt.pos/com.kt.pos.BuyClick}; have you declared this activity in your AndroidManifest.xml?
02-04 12:33:52.161: E/AndroidRuntime(1260): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1541)
02-04 12:33:52.161: E/AndroidRuntime(1260): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1416)
02-04 12:33:52.161: E/AndroidRuntime(1260): at android.app.Activity.startActivityForResult(Activity.java:3351)
02-04 12:33:52.161: E/AndroidRuntime(1260): at android.app.Activity.startActivityForResult(Activity.java:3312)
02-04 12:33:52.161: E/AndroidRuntime(1260): at android.app.Activity.startActivity(Activity.java:3522)
02-04 12:33:52.161: E/AndroidRuntime(1260): at android.app.Activity.startActivity(Activity.java:3490)
02-04 12:33:52.161: E/AndroidRuntime(1260): at com.kt.pos.POSMainActivity$1.onFinish(POSMainActivity.java:21)
02-04 12:33:52.161: E/AndroidRuntime(1260): at android.os.CountDownTimer$1.handleMessage(CountDownTimer.java:118)
02-04 12:33:52.161: E/AndroidRuntime(1260): at android.os.Handler.dispatchMessage(Handler.java:99)
02-04 12:33:52.161: E/AndroidRuntime(1260): at android.os.Looper.loop(Looper.java:137)
02-04 12:33:52.161: E/AndroidRuntime(1260): at android.app.ActivityThread.main(ActivityThread.java:4745)
02-04 12:33:52.161: E/AndroidRuntime(1260): at java.lang.reflect.Method.invokeNative(Native Method)
02-04 12:33:52.161: E/AndroidRuntime(1260): at java.lang.reflect.Method.invoke(Method.java:511)
02-04 12:33:52.161: E/AndroidRuntime(1260): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
02-04 12:33:52.161: E/AndroidRuntime(1260): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
02-04 12:33:52.161: E/AndroidRuntime(1260): at dalvik.system.NativeStart.main(Native Method)
02-04 12:38:52.231: I/Process(1260): Sending signal. PID: 1260 SIG: 9
It should be either
<activity android:name=".BuyClick"></activity>
or
<activity android:name="com.kt.pos.BuyClick"></activity>
It needs to be fully qualified with the package name or preceded with a "." if it's in the main package.
try this :
<activity android:name="com.kt.pos.BuyClick"></activity>
Always use your package name with activity before defining them in menifest.
I'm getting this exception:
10-24 17:08:19.711: E/AndroidRuntime(1379): FATAL EXCEPTION: main
10-24 17:08:19.711: E/AndroidRuntime(1379): java.lang.RuntimeException: Unable to start activity ComponentInfo{br.com.campusfqm.cfqm/br.com.campusfqm.cfqm.DownloadManagerActivity}: java.lang.IllegalStateException: Unable to create directory: /mnt/sdcard/Download
10-24 17:08:19.711: E/AndroidRuntime(1379): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1736)
10-24 17:08:19.711: E/AndroidRuntime(1379): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1752)
10-24 17:08:19.711: E/AndroidRuntime(1379): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
10-24 17:08:19.711: E/AndroidRuntime(1379): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993)
10-24 17:08:19.711: E/AndroidRuntime(1379): at android.os.Handler.dispatchMessage(Handler.java:99)
10-24 17:08:19.711: E/AndroidRuntime(1379): at android.os.Looper.loop(Looper.java:126)
10-24 17:08:19.711: E/AndroidRuntime(1379): at android.app.ActivityThread.main(ActivityThread.java:3997)
10-24 17:08:19.711: E/AndroidRuntime(1379): at java.lang.reflect.Method.invokeNative(Native Method)
10-24 17:08:19.711: E/AndroidRuntime(1379): at java.lang.reflect.Method.invoke(Method.java:491)
10-24 17:08:19.711: E/AndroidRuntime(1379): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
10-24 17:08:19.711: E/AndroidRuntime(1379): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
10-24 17:08:19.711: E/AndroidRuntime(1379): at dalvik.system.NativeStart.main(Native Method)
10-24 17:08:19.711: E/AndroidRuntime(1379): Caused by: java.lang.IllegalStateException: Unable to create directory: /mnt/sdcard/Download
10-24 17:08:19.711: E/AndroidRuntime(1379): at android.app.DownloadManager$Request.setDestinationInExternalPublicDir(DownloadManager.java:466)
10-24 17:08:19.711: E/AndroidRuntime(1379): at br.com.campusfqm.cfqm.DownloadManagerActivity.download(DownloadManagerActivity.java:51)
10-24 17:08:19.711: E/AndroidRuntime(1379): at br.com.campusfqm.cfqm.DownloadManagerActivity.onCreate(DownloadManagerActivity.java:43)
10-24 17:08:19.711: E/AndroidRuntime(1379): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
10-24 17:08:19.711: E/AndroidRuntime(1379): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1700)
10-24 17:08:19.711: E/AndroidRuntime(1379): ... 11 more
Using the class DownloadManager, with this code:
DownloadManager.Request request = new DownloadManager.Request(Uri.parse("http://centraldemangas.com.br/forum/dbtech/vbshop/images/gifts/pidgey.gif"));
request.setAllowedNetworkTypes(Request.NETWORK_MOBILE | Request.NETWORK_WIFI);
request.setAllowedOverRoaming(false);
request.setTitle("pidgey.gif");
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,"pid.gif");
id = downloadManager.enqueue(request);
The exception is pointing to request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,"pid.gif");
The problem is in
Unable to create directory: /mnt/sdcard/Download
Try this:
String name = Environment.getExternalStorageDirectory().getAbsolutePath();
name += "/YourDirectoryName/" ;
Do you have the proper permissions in your Manifest ?
See WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE permissions
I think you didn't give a sd card size when you crated the emulator.
i want to play mp3 file which is streamed mp3 file. i tried below link example
http://blog.pocketjourney.com/2008/04/04/tutorial-custom-media-streaming-for-androids-mediaplayer/
but the bellow error is coming
02-04 20:22:48.960: ERROR/PlayerDriver(31): Command PLAYER_PREPARE completed with an error or info PVMFErrResource
02-04 20:22:48.970: ERROR/MediaPlayer(425): error (1, -17)
02-04 20:22:48.989: WARN/PlayerDriver(31): PVMFInfoErrorHandlingComplete
02-04 20:22:49.089: DEBUG/dalvikvm(425): GC freed 4622 objects / 982864 bytes in 120ms
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): Error updating to newly loaded content.
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): java.io.IOException: Prepare failed.: status=0x1
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at android.media.MediaPlayer.prepare(Native Method)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at com.Boodang.StreamingMediaPlayer.createMediaPlayer(StreamingMediaPlayer.java:210)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at com.Boodang.StreamingMediaPlayer.transferBufferToMediaPlayer(StreamingMediaPlayer.java:239)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at com.Boodang.StreamingMediaPlayer.access$3(StreamingMediaPlayer.java:219)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at com.Boodang.StreamingMediaPlayer$2.run(StreamingMediaPlayer.java:160)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at android.os.Handler.handleCallback(Handler.java:587)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at android.os.Handler.dispatchMessage(Handler.java:92)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at android.os.Looper.loop(Looper.java:123)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at android.app.ActivityThread.main(ActivityThread.java:4363)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at java.lang.reflect.Method.invokeNative(Native Method)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at java.lang.reflect.Method.invoke(Method.java:521)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at dalvik.system.NativeStart.main(Native Method)
so please tell me what i will do and i hope there is better way to do this one . so please tell me how to stream the mp3 file and play the mp3 file.
Thank you.
Best Regards.
First, that blog post is nearly three years old. Never use Android blog posts from that long ago.
Second, at least through Android 2.2, streaming MP3 files was not supported over RTSP. I think it works over HTTP.
Beyond that, make sure the URL you are using actually is reachable from your device or emulator. For example, you need the INTERNET permission in your app, your emulator needs to have Internet access, etc.
In the future, you might consider supplying source code, as a stack trace alone is usually insufficient to get assistance from anyone.