single WebView layout to view urls from my main activity - android

I want to reuse a custom xml which I for various links from my main Activity.
I assume it's using a LayoutInflater.
But I am struggling with the code.
I was using the main_Activity xml for the code originally.
But I thought it would save space in the app if it inflated the same WebView for all the links within the app.
this is the xml for the custom layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:id="#+id/MyWebView">
<WebView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/webViewCustom">
</WebView>
</LinearLayout>
then this is the Java code I have tried.
I think that might be where my problem lies
switch (position){
case 0:
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(view.getWidth(),view.getHeight());
lp.leftMargin = (int) view.getX();
lp.topMargin = (int) view.getY();
LayoutInflater li = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
RelativeLayout ll = (RelativeLayout) li.inflate(R.layout.custom_webview, null);
webViewCustom.getSettings().setJavaScriptEnabled(true);
webViewCustom.getSettings().setBuiltInZoomControls(true);
webViewCustom.loadUrl(AeonnoxCusBckGrndMJDUrl);
MjdLayout.addView(ll, lp);
break;
this is how originaly had it within my mainActivity java. and each link has a seperate webView attached to a drawer. but i want 1 Activity that inflates/Opens all links when each button is pressed it just reuses the one view
TrustedSellersDrawer.openDrawer(MJDwebViewDrawerRight);
MJDwebViewDrawerRight.getSettings().setJavaScriptEnabled(true);
MJDwebViewDrawerRight.getSettings().setBuiltInZoomControls(true);
MJDwebViewDrawerRight.loadUrl(AeonnoxCusBckGrndMJDUrl);
The logcat
11-13 18:13:46.578 552-587/? W/System.err﹕ at libcore.io.IoBridge.open(IoBridge.java:409)
11-13 18:13:46.578 552-587/? W/System.err﹕ at java.io.FileOutputStream.<init>(FileOutputStream.java:88)
11-13 18:13:46.578 552-587/? W/System.err﹕ at java.io.FileOutputStream.<init>(FileOutputStream.java:73)
11-13 18:13:46.578 552-587/? W/System.err﹕ at com.sec.android.hardware.SecHardwareInterface.setBatteryADC(SecHardwareInterface.java:393)
11-13 18:13:46.578 552-587/? W/System.err﹕ at com.android.server.power.PowerManagerService$DisplayBlankerImpl$1.run(PowerManagerService.java:5324)
11-13 18:13:46.578 552-587/? W/System.err﹕ at android.os.Handler.handleCallback(Handler.java:733)
11-13 18:13:46.578 552-587/? W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:95)
11-13 18:13:46.578 552-587/? W/System.err﹕ at android.os.Looper.loop(Looper.java:146)
11-13 18:13:46.578 552-587/? W/System.err﹕ at android.os.HandlerThread.run(HandlerThread.java:61)
11-13 18:13:46.578 552-587/? W/System.err﹕ Caused by: libcore.io.ErrnoException: open failed: EACCES (Permission denied)
11-13 18:13:46.578 552-587/? W/System.err﹕ at libcore.io.Posix.open(Native Method)
11-13 18:13:46.578 552-587/? W/System.err﹕ at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
11-13 18:13:46.578 552-587/? W/System.err﹕ at libcore.io.IoBridge.open(IoBridge.java:393)
11-13 18:13:46.578 552-587/? W/System.err﹕ ... 8 more
my last few questions have been marked down quite alot for unknown reasons, so please be nice.

Related

Picasso is not loading images from the external storage

Using Picasso (version 2.5.2) in my android project and trying to load all the images stored in the device in a grid view. Picasso is successfully loading all the images stored in the internal storage but not loading those from the external storage. Also, not getting any errors in the log.
I also checked if the file exists and loaded that successfully in a view using Glide library.
Sample external file path:
/storage/0403-0201/DCIM/Camera/IMG_20180309_120329.jpg
#CommonsWare, Thanks a lot! I attached Picasso.Listener and got the following stack trace-
W/System.err﹕ java.io.IOException: Cannot reset
W/System.err﹕ at com.squareup.picasso.MarkableInputStream.reset(MarkableInputStream.java:99)
W/System.err﹕ at com.squareup.picasso.BitmapHunter.decodeStream(BitmapHunter.java:140)
W/System.err﹕ at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:217)
W/System.err﹕ at com.squareup.picasso.BitmapHunter.run(BitmapHunter.java:159)
W/System.err﹕ at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
W/System.err﹕ at java.util.concurrent.FutureTask.run(FutureTask.java:237)
W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
W/System.err﹕ at java.lang.Thread.run(Thread.java:841)
W/System.err﹕ at com.squareup.picasso.Utils$PicassoThread.run(Utils.java:394)
W/System.err﹕ java.io.IOException: Cannot reset
W/System.err﹕ at com.squareup.picasso.MarkableInputStream.reset(MarkableInputStream.java:99)
W/System.err﹕ at com.squareup.picasso.BitmapHunter.decodeStream(BitmapHunter.java:140)
W/System.err﹕ at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:217)
W/System.err﹕ at com.squareup.picasso.BitmapHunter.run(BitmapHunter.java:159)
W/System.err﹕ at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
W/System.err﹕ at java.util.concurrent.FutureTask.run(FutureTask.java:237)
W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
W/System.err﹕ at java.lang.Thread.run(Thread.java:841)
W/System.err﹕ at com.squareup.picasso.Utils$PicassoThread.run(Utils.java:394)
I explored this error and found that Picasso 2.5.2 does not display big images and same has been filed as a bug on Picasso github page.
https://github.com/square/picasso/issues/907
Solution: Picasso 2.5.x is having the bug but version 2.4.0 is working fine.

Writing to SD Card always failing

I am trying to move files from any location (including internal device storage)
to SD Card,
For that I Have
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
in my manifest, and checked that it did work by checking if premissions are granted using :
Contex.checkCallingOrSelfPermission("android.permission.WRITE_EXTERNAL_STORAGE") and Contex.checkCallingOrSelfPermission("android.permission.READ_EXTERNAL_STORAGE")
and I have tried 3 diffrent ways to do that :
Files.move(original, newPath1), which comes with Guava com.google.common.io
this method :
public static void move(File src, File dst) throws IOException {
FileInputStream inStream = new FileInputStream(src);
FileOutputStream outStream = new FileOutputStream(dst);
FileChannel inChannel = inStream.getChannel();
FileChannel outChannel = outStream.getChannel();
inChannel.transferTo(0, inChannel.size(), outChannel);
inStream.close();
outStream.close();
}
original.renameTo(newPath1);
I read alot of SO posts about this, and all solutions i tried did not work, I made sure the SD Card is mounted, and that i didnt have my device connected to PC while trying. I even tried 2 diffrent devices with SD Cards. Notice that i could access the image with BitmapFactory.decode() with the exact same path and i could load that image to imageview.
I am always getting EACCES (Permission denied). I dont know what else to do to solve this :(
11-13 11:11:54.358 19192-19372/xaday.ofek.ron.xaday W/System.err: java.io.FileNotFoundException: /storage/sdcard1/DCIM/thai2/IMG-20150702-WA0001.jpg: open failed: EACCES (Permission denied)
11-13 11:11:54.369 19192-19372/xaday.ofek.ron.xaday W/System.err: at libcore.io.IoBridge.open(IoBridge.java:465)
11-13 11:11:54.369 19192-19372/xaday.ofek.ron.xaday W/System.err: at java.io.FileOutputStream.<init>(FileOutputStream.java:87)
11-13 11:11:54.369 19192-19372/xaday.ofek.ron.xaday W/System.err: at com.google.common.io.Files$FileByteSink.openStream(Files.java:245)
11-13 11:11:54.369 19192-19372/xaday.ofek.ron.xaday W/System.err: at com.google.common.io.Files$FileByteSink.openStream(Files.java:233)
11-13 11:11:54.369 19192-19372/xaday.ofek.ron.xaday W/System.err: at com.google.common.io.ByteSource.copyTo(ByteSource.java:248)
11-13 11:11:54.369 19192-19372/xaday.ofek.ron.xaday W/System.err: at com.google.common.io.Files.copy(Files.java:458)
11-13 11:11:54.369 19192-19372/xaday.ofek.ron.xaday W/System.err: at com.google.common.io.Files.move(Files.java:673)
11-13 11:11:54.369 19192-19372/xaday.ofek.ron.xaday W/System.err: at xaday.ofek.ron.xaday.XaDayIntentService.handleActionMove(XaDayIntentService.java:128)
11-13 11:11:54.369 19192-19372/xaday.ofek.ron.xaday W/System.err: at xaday.ofek.ron.xaday.XaDayIntentService.onHandleIntent(XaDayIntentService.java:84)
11-13 11:11:54.370 19192-19372/xaday.ofek.ron.xaday W/System.err: at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
11-13 11:11:54.370 19192-19372/xaday.ofek.ron.xaday W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
11-13 11:11:54.370 19192-19372/xaday.ofek.ron.xaday W/System.err: at android.os.Looper.loop(Looper.java:211)
11-13 11:11:54.370 19192-19372/xaday.ofek.ron.xaday W/System.err: at android.os.HandlerThread.run(HandlerThread.java:61)
11-13 11:11:54.370 19192-19372/xaday.ofek.ron.xaday W/System.err: Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
11-13 11:11:54.370 19192-19372/xaday.ofek.ron.xaday W/System.err: at libcore.io.Posix.open(Native Method)
11-13 11:11:54.370 19192-19372/xaday.ofek.ron.xaday W/System.err: at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
11-13 11:11:54.370 19192-19372/xaday.ofek.ron.xaday W/System.err: at libcore.io.IoBridge.open(IoBridge.java:451)
11-13 11:11:54.370 19192-19372/xaday.ofek.ron.xaday W/System.err: ... 12 more
11-13 11:11:54.370 19192-19372/xaday.ofek.ron.xaday W/System.err: java.io.FileNotFoundException: /storage/sdcard1/DCIM/thai2/IMG-20150702-WA0001.jpg: open failed: EACCES (Permission denied)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at libcore.io.IoBridge.open(IoBridge.java:465)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at java.io.FileOutputStream.<init>(FileOutputStream.java:87)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at java.io.FileOutputStream.<init>(FileOutputStream.java:72)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at xaday.ofek.ron.xaday.FileUtils.move(FileUtils.java:36)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at xaday.ofek.ron.xaday.XaDayIntentService.handleActionMove(XaDayIntentService.java:136)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at xaday.ofek.ron.xaday.XaDayIntentService.onHandleIntent(XaDayIntentService.java:84)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at android.os.Looper.loop(Looper.java:211)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at android.os.HandlerThread.run(HandlerThread.java:61)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at libcore.io.Posix.open(Native Method)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: at libcore.io.IoBridge.open(IoBridge.java:451)
11-13 11:11:54.371 19192-19372/xaday.ofek.ron.xaday W/System.err: ... 9 more
Just to make sure I was not locking the file in some way, I used another file manager app to execute the same file move - and it worked! why is it not working for me?!
anyone has an idea?
On Android Kitkat (4.4), Google has changed how the developers can access to the removable storage (SD card). Quoting from source.android.com:
The WRITE_EXTERNAL_STORAGE permission must only grant write access to
the primary external storage on a device. Apps must not be allowed to
write to secondary external storage devices, except in their
package-specific directories as allowed by synthesized permissions.
Restricting writes in this way ensures the system can clean up files
when applications are uninstalled.
For this reason, even with the WRITE_EXTERNAL_STORAGE permission, you can't write on the SD card on KitKat and higher versions.
On Android Lollipop (5.0), Google adds a new set of API that allows the developers to manage the file on the SD Card through the Storage Access Framework.
This StackOverflow answer explains in detail how to use the new APIs and the existing limitations:
How to use the new SD card access API presented for Android 5.0 (Lollipop)?
Is the "uses-permission" tag outside of the "application" tag in the manifest.xml?

How can i run Jacoco in android studio for code coverage

I have a debug flavor in android studio already. My gradle config file for my app module contains the following:
debug{
testCoverageEnabled true
}
then i run the following command in the terminal:
gradlew createDebugCoverageReport
and indeed I get a report but the app also crashes with a read only error and I cannot seem to figure it out. I'm using a mac. Here is the stack trace:
**java.io.FileNotFoundException: /jacoco.exec: open failed: EROFS (Read-only file system)**
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at libcore.io.IoBridge.open(IoBridge.java:416)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at java.io.FileOutputStream.<init>(FileOutputStream.java:88)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at org.jacoco.agent.rt.internal_932a715.output.FileOutput.openFile(FileOutput.java:67)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at org.jacoco.agent.rt.internal_932a715.output.FileOutput.startup(FileOutput.java:49)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at org.jacoco.agent.rt.internal_932a715.Agent.startup(Agent.java:122)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at org.jacoco.agent.rt.internal_932a715.Agent.getInstance(Agent.java:50)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at org.jacoco.agent.rt.internal_932a715.Offline.<clinit>(Offline.java:31)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at mypackage.org.duckduck.MainApplication.$jacocoInit(MainApplication.java)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at mypackage.org.duckduck.MainApplication.<clinit>(MainApplication.java)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at java.lang.Class.newInstanceImpl(Native Method)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at java.lang.Class.newInstance(Class.java:1319)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at android.app.Instrumentation.newApplication(Instrumentation.java:983)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at android.app.Instrumentation.newApplication(Instrumentation.java:968)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at android.app.LoadedApk.makeApplication(LoadedApk.java:499)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4480)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at android.app.ActivityThread.access$1300(ActivityThread.java:146)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1300)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:99)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at android.os.Looper.loop(Looper.java:137)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at android.app.ActivityThread.main(ActivityThread.java:5168)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at java.lang.reflect.Method.invokeNative(Native Method)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:511)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:564)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at dalvik.system.NativeStart.main(Native Method)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ Caused by: libcore.io.ErrnoException: open failed: EROFS (Read-only file system)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at libcore.io.Posix.open(Native Method)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ at libcore.io.IoBridge.open(IoBridge.java:400)
03-01 00:04:56.871 19006-19006/mypackage.org.duckduck W/System.err﹕ ... 24 more
I had the same problem running jacoco on an USB device.
Using Genymotion solved the issue.
Since, I dont see your entire gradle file I'm not sure if you already have this the right way but one suggestion is don't apply the jacoco plug-in explicitly if you are in the gradle file. Gradle's most recent version comes packaged with JaCoCo.
This was breaking my tests until recently when I tried without that line.
Another thing is I just run
gradle connectedCheck
from the terminal(Mac) or command prompt (windows) and this generates the html code coverage report for me.
Hopefully trying this fixes your issue too.
This warning seems irrelevant:
The error message went away when mounting the root file system read-write
mount -o remount,rw rootfs /
, and just setting write permissions for all users (only do this on an emulator!!!, it is really insecure)
chmod 777 /
Unfortunately, my tests were broken before and after, changing this did not fix them at all.
So unless there is a real problem, you could just treat this as a message that requires no action.

Titanium Android App Markeplace Build not starting

I made an Android app with Titanium Studio. It works perfecly as long as i run it in debug mode but as soon as i use the apk that's generated by the built in marketplace distribution my app gets stuck when the loading screen is shown. No error Message is displayed.
I created a keystore and verified the apk after it was built. no errors.
Any idea what i need to change?
DDMS:
11-13 21:57:26.142: I/ActivityManager(477): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.xxxx.xxxx/.xxxxActivity bnds=[360,74][536,302]} from pid 767
11-13 21:57:26.142: W/ContextImpl(477): Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1078 com.android.server.am.ActivityStack.SendToPermission:2575 com.android.server.am.ActivityStack.startActivityUncheckedLocked:3177 com.android.server.am.ActivityStack.startActivityLocked:2788 com.android.server.am.ActivityStack.startActivityMayWait:3343
11-13 21:57:26.149: D/PowerManagerService(477): acquireWakeLockInternal: lock=1112740064, flags=0x1, tag="ActivityManager-Launch", ws=null, uid=1000, pid=477
11-13 21:57:26.149: D/PowerManagerNotifier(477): onWakeLockAcquired: flags=1, tag="ActivityManager-Launch", ownerUid=1000, ownerPid=477, workSource=null
11-13 21:57:26.149: D/PowerManagerService(477): Update history[5] wakeLock: flags=0x1, tag="ActivityManager-Launch", uid=1000, pid=477, timeStamp=1384376246150, timeSum=8638
11-13 21:57:26.149: D/PowerManagerService(477): updateWakeLockSummaryLocked: mWakefulness=Awake, mWakeLockSummary=0x1
11-13 21:57:26.149: D/PowerManagerService(477): updateScreenStateLocked: mDisplayReady=true, newScreenState=2, mWakefulness=1, mWakeLockSummary=0x1, mUserActivitySummary=0x1, mBootCompleted=true
11-13 21:57:26.156: I/ComBroadcastReceiver(28917): ComBroadcastReceiver action = android.server.am.ActivityStack.taskstatechange
11-13 21:57:26.166: I/ActivityManager(477): Start proc com.xxxx.xxxx for activity com.xxxx.xxxx/.xxxxActivity: pid=10596 uid=10176 gids={50176, 1015, 3003, 1028}
11-13 21:57:26.179: I/dalvikvm(10596): Turning on JNI app bug workarounds for target SDK version 10...
11-13 21:57:26.202: D/Sensors(477): sensors_poll_context_t->activate(handle: 0, enabled: 1)
11-13 21:57:26.202: D/PowerManagerService(477): handleSandman: canDream=false, mWakefulness=Awake
11-13 21:57:26.206: D/Sensors(477): virtual int AccelerometerSensor::enable(int32_t, int): fd (230 ),en (1),flags(1), mEnabled(0),input_sys_path (/sys/class/input/event4/device/device/enable)
11-13 21:57:26.206: D/Sensors(477): sensors_poll_context_t->setDelay(handle: 0, ns: 200000000)
11-13 21:57:26.206: D/Sensors(477): sensors_poll_context_t->setDelay(handle: 0, ns: 66667000)
11-13 21:57:26.206: W/ActivityRecord(477): goujw packagename: com.xxxx.xxxx
11-13 21:57:26.209: W/ActivityRecord(477): goujw userId: 0
11-13 21:57:26.242: D/CubicBezierInterpolator(477): CubicBezierInterpolator mControlPoint1x = 0.5, mControlPoint1y = 0.2, mControlPoint2x = 0.6, mControlPoint2y = 1.0
11-13 21:57:26.249: W/System.err(10596): java.io.FileNotFoundException: /data/cust/xml/hw_launcher_load_icon.xml: open failed: ENOENT (No such file or directory)
11-13 21:57:26.249: W/System.err(10596): at libcore.io.IoBridge.open(IoBridge.java:409)
11-13 21:57:26.252: I/PowerManagerService(477): state=2
11-13 21:57:26.252: W/System.err(10596): at java.io.FileInputStream.<init>(FileInputStream.java:109)
11-13 21:57:26.252: W/System.err(10596): at android.content.res.ResourcesEx.readDefaultConfig(ResourcesEx.java:808)
11-13 21:57:26.252: W/System.err(10596): at android.content.res.ResourcesEx.<init>(ResourcesEx.java:741)
11-13 21:57:26.252: W/System.err(10596): at android.app.ActivityThread.getTopLevelResources(ActivityThread.java:1721)
11-13 21:57:26.252: W/System.err(10596): at android.app.ActivityThread.getTopLevelResources(ActivityThread.java:1752)
11-13 21:57:26.256: W/System.err(10596): at android.app.LoadedApk.getResources(LoadedApk.java:485)
11-13 21:57:26.256: W/System.err(10596): at android.app.ContextImpl.init(ContextImpl.java:1911)
11-13 21:57:26.256: W/System.err(10596): at android.app.ContextImpl.init(ContextImpl.java:1904)
11-13 21:57:26.256: W/System.err(10596): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4269)
11-13 21:57:26.256: W/System.err(10596): at android.app.ActivityThread.access$1300(ActivityThread.java:145)
11-13 21:57:26.256: W/System.err(10596): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1306)
11-13 21:57:26.256: W/System.err(10596): at android.os.Handler.dispatchMessage(Handler.java:99)
11-13 21:57:26.256: W/System.err(10596): at android.os.Looper.loop(Looper.java:137)
11-13 21:57:26.256: W/System.err(10596): at android.app.ActivityThread.main(ActivityThread.java:5095)
11-13 21:57:26.256: W/System.err(10596): at java.lang.reflect.Method.invokeNative(Native Method)
11-13 21:57:26.256: W/System.err(10596): at java.lang.reflect.Method.invoke(Method.java:511)
11-13 21:57:26.256: W/System.err(10596): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
11-13 21:57:26.256: W/System.err(10596): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
11-13 21:57:26.256: W/System.err(10596): at dalvik.system.NativeStart.main(Native Method)
11-13 21:57:26.256: W/System.err(10596): Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
11-13 21:57:26.259: W/System.err(10596): at libcore.io.Posix.open(Native Method)
11-13 21:57:26.259: W/System.err(10596): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
11-13 21:57:26.259: W/System.err(10596): at libcore.io.IoBridge.open(IoBridge.java:400)
11-13 21:57:26.259: W/System.err(10596): ... 19 more
11-13 21:57:26.272: I/TiApplication(10596): (main) [0,0] checkpoint, app created.
11-13 21:57:26.356: W/System.err(10596): Invalid int: ""
11-13 21:57:26.416: I/TiApplication(10596): (main) [141,141] Titanium 3.1.3 (2013/09/18 12:01 222f4d1)
11-13 21:57:26.482: I/TiApplication(10596): (main) [68,209] Titanium Javascript runtime: v8
11-13 21:57:26.482: D/dalvikvm(10596): Trying to load lib /data/app-lib/com.xxxx.xxxx-2/libstlport_shared.so 0x424249f0
11-13 21:57:26.486: D/dalvikvm(10596): Added shared lib /data/app-lib/com.xxxx.xxxx-2/libstlport_shared.so 0x424249f0
11-13 21:57:26.486: D/dalvikvm(10596): No JNI_OnLoad found in /data/app-lib/com.xxxx.xxxx-2/libstlport_shared.so 0x424249f0, skipping init
11-13 21:57:26.486: D/dalvikvm(10596): Trying to load lib /data/app-lib/com.xxxx.xxxx-2/libkroll-v8.so 0x424249f0
11-13 21:57:26.496: D/dalvikvm(10596): Added shared lib /data/app-lib/com.xxxx.xxxx-2/libkroll-v8.so 0x424249f0
11-13 21:57:26.502: I/TiRootActivity(10596): (main) [0,0] checkpoint, on root activity create, savedInstanceState: null
11-13 21:57:26.502: I/TiApplication(10596): (main) [1,1] Analytics have been disabled
11-13 21:57:26.706: W/V8Object(10596): Runtime disposed, cannot set property 'userAgent'

File write permission error in Android

I am writing a file to SDCard and set <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> it works good upto 3.x but on 4.0 it gives the below error.
java.io.IOException: open failed: EACCES (Permission denied)
at java.io.File.createNewFile(File.java:940)
at com.gt.mLearning.app.VideoViewActivity.copyFile(VideoViewActivity.java:204)
at com.gt.mLearning.app.VideoViewActivity.access$3(VideoViewActivity.java:193)
at com.gt.mLearning.app.VideoViewActivity$Loader.doInBackground(VideoViewActivity.java:61)
at com.gt.mLearning.app.VideoViewActivity$Loader.doInBackground(VideoViewActivity.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:264)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Caused by: libcore.io.ErrnoException: open failed: EACCES (Permission denied)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
at java.io.File.createNewFile(File.java:933)
Any help or suggestion?
rohit
Just guessing but did you probably have your phone still connected to the computer? This error might happen if your sd card is still locked as a usb device.
Hope this helped,
Tobias
Latter on I discovered that the issue is device specific. I installed the File Manager app from Android market and it shows no write permission. It mean the Android OS implementation of that manufacturer do not provide write permission which is causing the issue.
Probably you have hard-coded the external storage directory and it works on particular devices.
Environment.getExternalStorageDirectory();
Posting your code will help much more than just the log.
You may check you've just updated your Android O/S, too. Some major change cause sdcard problem. For me, I update my Android O/S in SHV-E160K from 2.3.5 to 4.1.2 with Odin which is samsung firmware update application. And I faced problem.
My detailed error message is as follows :
02-14 11:00:43.057 22288-22288/? W/System.err﹕ java.io.IOException: open failed: EACCES (Permission denied)
02-14 11:00:43.057 22288-22288/? W/System.err﹕ at java.io.File.createNewFile(File.java:940)
02-14 11:00:43.057 22288-22288/? W/System.err﹕ at com.sec.android.util.IAPDeviceInfoEditor.activity.EditorActivity.createDeviceInfo(EditorActivity.java:222)
02-14 11:00:43.057 22288-22288/? W/System.err﹕ at com.sec.android.util.IAPDeviceInfoEditor.activity.EditorActivity.onClick(EditorActivity.java:121)
02-14 11:00:43.057 22288-22288/? W/System.err﹕ at java.lang.reflect.Method.invokeNative(Native Method)
02-14 11:00:43.057 22288-22288/? W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:511)
02-14 11:00:43.057 22288-22288/? W/System.err﹕ at android.view.View$1.onClick(View.java:3685)
02-14 11:00:43.057 22288-22288/? W/System.err﹕ at android.view.View.performClick(View.java:4192)
02-14 11:00:43.067 22288-22288/? W/System.err﹕ at android.view.View$PerformClick.run(View.java:17248)
02-14 11:00:43.067 22288-22288/? W/System.err﹕ at android.os.Handler.handleCallback(Handler.java:615)
02-14 11:00:43.067 172-485/? V/AudioHardwareMSM8660﹕ open driver
02-14 11:00:43.067 22288-22288/? W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:92)
02-14 11:00:43.067 22288-22288/? W/System.err﹕ at android.os.Looper.loop(Looper.java:137)
02-14 11:00:43.067 22288-22288/? W/System.err﹕ at android.app.ActivityThread.main(ActivityThread.java:4950)
02-14 11:00:43.067 22288-22288/? W/System.err﹕ at java.lang.reflect.Method.invokeNative(Native Method)
02-14 11:00:43.067 22288-22288/? W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:511)
02-14 11:00:43.067 22288-22288/? W/System.err﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:997)
02-14 11:00:43.067 22288-22288/? W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:764)
02-14 11:00:43.067 22288-22288/? W/System.err﹕ at dalvik.system.NativeStart.main(Native Method)
02-14 11:00:43.067 22288-22288/? W/System.err﹕ Caused by: libcore.io.ErrnoException: open failed: EACCES (Permission denied)
02-14 11:00:43.067 22288-22288/? W/System.err﹕ at libcore.io.Posix.open(Native Method)
02-14 11:00:43.067 22288-22288/? W/System.err﹕ at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
02-14 11:00:43.067 22288-22288/? W/System.err﹕ at java.io.File.createNewFile(File.java:933)
02-14 11:00:43.067 22288-22288/? W/System.err﹕ ... 16 more
The reason is 4.1.2 couldn't recognize file system in 2.3.5. I solve this formatting sdcard storage. format doesn't mean delete your personal information such as address, memo or history. After format, it works like magic.
This may help you.
I faced the same issue when writing the file on sdcard. I have set all required permission to write the file but i used file object like below:
Wrong :
File myFile = new File(Environment.getExternalStorageDirectory().getAbsoluteFile()+fileName);
Correct:
File myFile = new File(Environment.getExternalStorageDirectory().getAbsoluteFile(), fileName);
That means the path was wrong.

Categories

Resources