» »

[android] shranjevanje slike - eror

[android] shranjevanje slike - eror

g333kk ::

Ko poskušam shraniti sliko, mi izpiše tele napake, koda je sicer taka naj bi bilo pa napačno:
 fos = new FileOutputStream(file);

Celotna koda shranjevanja je spodaj.
09-09 19:05:12.676: W/KeyCharacterMap(4513): No keyboard for id 0
09-09 19:05:12.676: W/KeyCharacterMap(4513): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
09-09 19:05:18.426: E/Panel(4513): FileNotFoundException
09-09 19:05:18.426: E/Panel(4513): java.io.FileNotFoundException: /sdcard/androidpaint/2012Sep09190518.9.png
09-09 19:05:18.426: E/Panel(4513): 	at org.apache.harmony.luni.platform.OSFileSystem.open(OSFileSystem.java:244)
09-09 19:05:18.426: E/Panel(4513): 	at java.io.FileOutputStream.<init>(FileOutputStream.java:97)
09-09 19:05:18.426: E/Panel(4513): 	at java.io.FileOutputStream.<init>(FileOutputStream.java:69)
09-09 19:05:18.426: E/Panel(4513): 	at somitsolutions.training.android.androidpaint.AndroidPaint.onOptionsItemSelected(AndroidPaint.java:318)
09-09 19:05:18.426: E/Panel(4513): 	at android.app.Activity.onMenuItemSelected(Activity.java:2170)
09-09 19:05:18.426: E/Panel(4513): 	at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:730)
09-09 19:05:18.426: E/Panel(4513): 	at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:139)
09-09 19:05:18.426: E/Panel(4513): 	at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855)
09-09 19:05:18.426: E/Panel(4513): 	at com.android.internal.view.menu.ExpandedMenuView.invokeItem(ExpandedMenuView.java:89)
09-09 19:05:18.426: E/Panel(4513): 	at com.android.internal.view.menu.ExpandedMenuView.onItemClick(ExpandedMenuView.java:93)
09-09 19:05:18.426: E/Panel(4513): 	at android.widget.AdapterView.performItemClick(AdapterView.java:284)
09-09 19:05:18.426: E/Panel(4513): 	at android.widget.ListView.performItemClick(ListView.java:3285)
09-09 19:05:18.426: E/Panel(4513): 	at android.widget.AbsListView$PerformClick.run(AbsListView.java:1640)
09-09 19:05:18.426: E/Panel(4513): 	at android.os.Handler.handleCallback(Handler.java:587)
09-09 19:05:18.426: E/Panel(4513): 	at android.os.Handler.dispatchMessage(Handler.java:92)
09-09 19:05:18.426: E/Panel(4513): 	at android.os.Looper.loop(Looper.java:123)
09-09 19:05:18.426: E/Panel(4513): 	at android.app.ActivityThread.main(ActivityThread.java:4363)
09-09 19:05:18.426: E/Panel(4513): 	at java.lang.reflect.Method.invokeNative(Native Method)
09-09 19:05:18.426: E/Panel(4513): 	at java.lang.reflect.Method.invoke(Method.java:521)
09-09 19:05:18.426: E/Panel(4513): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
09-09 19:05:18.426: E/Panel(4513): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
09-09 19:05:18.426: E/Panel(4513): 	at dalvik.system.NativeStart.main(Native Method)



 case R.id.itemSaveImage:
    	
    	 Calendar currentDate = Calendar.getInstance();
    	  SimpleDateFormat formatter= new SimpleDateFormat("yyyyMMMddHmmss");
    	  String dateNow = formatter.format(currentDate.getTime());
    	  file = new File(mImagePath + "/" + dateNow +".9.png");
    	  FileOutputStream fos;
    	  try {
            fos = new FileOutputStream(file);
            wallPaperBitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
            fos.close();
    	  } catch (FileNotFoundException e) {
            Log.e("Panel", "FileNotFoundException", e);
    	  } 
    	  catch (IOException e) {
            Log.e("Panel", "IOEception", e);
        }

kloko ::

Za začetek dodaj:

file.createNewFile();

za obstoječo vrstico:

file = new File(mImagePath + "/" + dateNow +".9.png");


Pa verjetno je v nadaljevanju še kaj drugega narobe. Tisti primer, iz katerega prepisuješ, je cel "ohroščen".

L.p., Kloko

g333kk ::

in kako razhroščim primer ;( oz popravim zadeve, oz kako popravim ostale zadevo

Zgodovina sprememb…

  • spremenilo: g333kk ()


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

[Android] Splošno

Oddelek: Programiranje
351998 (1128) piki12
»

Programiranje problem android

Oddelek: Programiranje
51166 (931) g333kk
»

android črta

Oddelek: Programiranje
412391 (1662) g333kk
»

[android] vstavljanje slike

Oddelek: Programiranje
71232 (1129) messi
»

[android] crash

Oddelek: Programiranje
61329 (1138) messi

Več podobnih tem