i have given read write permission in manifest file ,but i am getting this exception.
07-17 15:23:47.886: W/System.err(384): java.io.FileNotFoundException: /data/test.xlsx (Permission denied)
07-17 15:23:47.906: W/System.err(384): at org.apache.harmony.luni.platform.OSFileSystem.open(Native Method)
07-17 15:23:47.915: W/System.err(384): at dalvik.system.BlockGuard$WrappedFileSystem.open(BlockGuard.java:232)
07-17 15:23:47.915: W/System.err(384): at java.io.FileOutputStream.<init>(FileOutputStream.java:94)
07-17 15:23:47.915: W/System.err(384): at java.io.FileOutputStream.<init>(FileOutputStream.java:165)
07-17 15:23:47.915: W/System.err(384): at java.io.FileOutputStream.<init>(FileOutputStream.java:144)
07-17 15:23:47.915: W/System.err(384): at com.example.excelreader.MainActivity.onCreate(MainActivity.java:44)
07-17 15:23:47.915: W/System.err(384): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-17 15:23:47.926: W/System.err(384): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
07-17 15:23:47.926: W/System.err(384): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
07-17 15:23:47.926: W/System.err(384): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-17 15:23:47.926: W/System.err(384): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
07-17 15:23:47.926: W/System.err(384): at android.os.Handler.dispatchMessage(Handler.java:99)
07-17 15:23:47.926: W/System.err(384): at android.os.Looper.loop(Looper.java:130)
07-17 15:23:47.926: W/System.err(384): at android.app.ActivityThread.main(ActivityThread.java:3683)
07-17 15:23:47.936: W/System.err(384): at java.lang.reflect.Method.invokeNative(Native Method)
07-17 15:23:47.936: W/System.err(384): at java.lang.reflect.Method.invoke(Method.java:507)
07-17 15:23:47.936: W/System.err(384): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-17 15:23:47.936: W/System.err(384): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-17 15:23:47.957: W/System.err(384): at dalvik.system.NativeStart.main(Native Method)
/data is not accessbile from a normal user. Infact if your run from adb
adb shell ls /data
you will get
opendir failed, Permission denied
data has the following permission
drwxrwx--x system system 2013-07-16 10:09 data
Related
I am using appcompat_v7 for actionbar compatability & android-support-v4.jar for fragment compatability, but my app crashes in 2.2.
Logcat
07-17 12:43:27.785: I/dalvikvm(327): Could not find method android.content.pm.PackageManager.getActivityLogo, referenced from method android.support.v7.internal.widget.ActionBarView.<init>
07-17 12:43:27.785: W/dalvikvm(327): VFY: unable to resolve virtual method 319: Landroid/content/pm/PackageManager;.getActivityLogo (Landroid/content/ComponentName;)Landroid/graphics/drawable/Drawable;
07-17 12:43:27.795: D/dalvikvm(327): VFY: replacing opcode 0x6e at 0x008b
07-17 12:43:27.795: I/dalvikvm(327): Could not find method android.content.pm.ApplicationInfo.loadLogo, referenced from method android.support.v7.internal.widget.ActionBarView.<init>
07-17 12:43:27.795: W/dalvikvm(327): VFY: unable to resolve virtual method 315: Landroid/content/pm/ApplicationInfo;.loadLogo (Landroid/content/pm/PackageManager;)Landroid/graphics/drawable/Drawable;
07-17 12:43:27.795: D/dalvikvm(327): VFY: replacing opcode 0x6e at 0x0099
07-17 12:43:27.805: D/dalvikvm(327): VFY: dead code 0x008e-0092 in Landroid/support/v7/internal/widget/ActionBarView;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;)V
07-17 12:43:27.805: D/dalvikvm(327): VFY: dead code 0x009c-00a0 in Landroid/support/v7/internal/widget/ActionBarView;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;)V
07-17 12:43:28.055: I/dalvikvm(327): Could not find method com.example.indianconstitution.MainActivity.invalidateOptionsMenu, referenced from method com.example.indianconstitution.MainActivity$1.onDrawerClosed
07-17 12:43:28.055: W/dalvikvm(327): VFY: unable to resolve virtual method 8698: Lcom/example/indianconstitution/MainActivity;.invalidateOptionsMenu ()V
07-17 12:43:28.055: D/dalvikvm(327): VFY: replacing opcode 0x6e at 0x002d
07-17 12:43:28.055: D/dalvikvm(327): VFY: dead code 0x0030-0030 in Lcom/example/indianconstitution/MainActivity$1;.onDrawerClosed (Landroid/view/View;)V
07-17 12:43:28.065: I/dalvikvm(327): Could not find method com.example.indianconstitution.MainActivity.invalidateOptionsMenu, referenced from method com.example.indianconstitution.MainActivity$1.onDrawerOpened
07-17 12:43:28.065: W/dalvikvm(327): VFY: unable to resolve virtual method 8698: Lcom/example/indianconstitution/MainActivity;.invalidateOptionsMenu ()V
07-17 12:43:28.065: D/dalvikvm(327): VFY: replacing opcode 0x6e at 0x002d
07-17 12:43:28.065: D/dalvikvm(327): VFY: dead code 0x0030-0030 in Lcom/example/indianconstitution/MainActivity$1;.onDrawerOpened (Landroid/view/View;)V
07-17 12:43:28.215: D/AndroidRuntime(327): Shutting down VM
07-17 12:43:28.225: W/dalvikvm(327): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
07-17 12:43:28.254: E/AndroidRuntime(327): FATAL EXCEPTION: main
07-17 12:43:28.254: E/AndroidRuntime(327): android.view.InflateException: Binary XML file line #7: Error inflating class <unknown>
07-17 12:43:28.254: E/AndroidRuntime(327): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
07-17 12:43:28.254: E/AndroidRuntime(327): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
07-17 12:43:28.254: E/AndroidRuntime(327): at com.example.indianconstitution.NavDrawerListAdapter.getView(NavDrawerListAdapter.java:44)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.widget.AbsListView.obtainView(AbsListView.java:1315)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.widget.ListView.makeAndAddView(ListView.java:1727)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.widget.ListView.fillDown(ListView.java:652)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.widget.ListView.fillFromTop(ListView.java:709)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.widget.ListView.layoutChildren(ListView.java:1580)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.widget.AbsListView.onLayout(AbsListView.java:1147)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.view.View.layout(View.java:7035)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:767)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.view.View.layout(View.java:7035)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.view.View.layout(View.java:7035)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.widget.LinearLayout.onLayout(LinearLayout.java:1042)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.view.View.layout(View.java:7035)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.view.View.layout(View.java:7035)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.view.View.layout(View.java:7035)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.view.ViewRoot.performTraversals(ViewRoot.java:1045)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.os.Handler.dispatchMessage(Handler.java:99)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.os.Looper.loop(Looper.java:123)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-17 12:43:28.254: E/AndroidRuntime(327): at java.lang.reflect.Method.invokeNative(Native Method)
07-17 12:43:28.254: E/AndroidRuntime(327): at java.lang.reflect.Method.invoke(Method.java:521)
07-17 12:43:28.254: E/AndroidRuntime(327): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-17 12:43:28.254: E/AndroidRuntime(327): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-17 12:43:28.254: E/AndroidRuntime(327): at dalvik.system.NativeStart.main(Native Method)
07-17 12:43:28.254: E/AndroidRuntime(327): Caused by: java.lang.reflect.InvocationTargetException
07-17 12:43:28.254: E/AndroidRuntime(327): at android.widget.TextView.<init>(TextView.java:321)
07-17 12:43:28.254: E/AndroidRuntime(327): at java.lang.reflect.Constructor.constructNative(Native Method)
07-17 12:43:28.254: E/AndroidRuntime(327): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.view.LayoutInflater.createView(LayoutInflater.java:500)
07-17 12:43:28.254: E/AndroidRuntime(327): ... 36 more
07-17 12:43:28.254: E/AndroidRuntime(327): Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x2
07-17 12:43:28.254: E/AndroidRuntime(327): at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.view.View.<init>(View.java:2036)
07-17 12:43:28.254: E/AndroidRuntime(327): at android.widget.TextView.<init>(TextView.java:327)
07-17 12:43:28.254: E/AndroidRuntime(327): ... 40 more
07-17 12:43:28.355: D/dalvikvm(327): GC_FOR_MALLOC freed 3423 objects / 301120 bytes in 90ms
Any Idea why am I getting this error ?
How can it be solved ?
Thanks in advance
You are calling methods that does not exist in Android 2.2 (but do exist in later versions). Use Lint tool to check your code and fix it.
I am using dummy surface in my code.It's working fine in Canvas HD running 4.2.1 but when the same app is deployed on my nexus 5/S 3 it gives RunTimeException on camera.takepicture
Here's my code
{
camera = Camera.open(cameraId);
if (camera != null)
{
SurfaceView dummy = new SurfaceView(context);
try {
camera.setPreviewDisplay(dummy.getHolder());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
camera.startPreview();
camera.takePicture(null, null, new PhotoHandler(context));
}
Logcat:
07-17 22:46:49.281: E/AndroidRuntime(481): FATAL EXCEPTION: main
07-17 22:46:49.281: E/AndroidRuntime(481): Process: com.example.ex, PID: 481
07-17 22:46:49.281: E/AndroidRuntime(481): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ex/com.example.ex.MainActivity}: java.lang.RuntimeException: takePicture failed
07-17 22:46:49.281: E/AndroidRuntime(481): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
07-17 22:46:49.281: E/AndroidRuntime(481): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
07-17 22:46:49.281: E/AndroidRuntime(481): at android.app.ActivityThread.access$800(ActivityThread.java:135)
07-17 22:46:49.281: E/AndroidRuntime(481): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
07-17 22:46:49.281: E/AndroidRuntime(481): at android.os.Handler.dispatchMessage(Handler.java:102)
07-17 22:46:49.281: E/AndroidRuntime(481): at android.os.Looper.loop(Looper.java:136)
07-17 22:46:49.281: E/AndroidRuntime(481): at android.app.ActivityThread.main(ActivityThread.java:5001)
07-17 22:46:49.281: E/AndroidRuntime(481): at java.lang.reflect.Method.invokeNative(Native Method)
07-17 22:46:49.281: E/AndroidRuntime(481): at java.lang.reflect.Method.invoke(Method.java:515)
07-17 22:46:49.281: E/AndroidRuntime(481): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
07-17 22:46:49.281: E/AndroidRuntime(481): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
07-17 22:46:49.281: E/AndroidRuntime(481): at dalvik.system.NativeStart.main(Native Method)
07-17 22:46:49.281: E/AndroidRuntime(481): Caused by: java.lang.RuntimeException: takePicture failed
07-17 22:46:49.281: E/AndroidRuntime(481): at android.hardware.Camera.native_takePicture(Native Method)
07-17 22:46:49.281: E/AndroidRuntime(481): at android.hardware.Camera.takePicture(Camera.java:1245)
07-17 22:46:49.281: E/AndroidRuntime(481): at android.hardware.Camera.takePicture(Camera.java:1190)
07-17 22:46:49.281: E/AndroidRuntime(481): at com.example.ex.MainActivity.capturephoto(MainActivity.java:63)
07-17 22:46:49.281: E/AndroidRuntime(481): at com.example.ex.MainActivity.onCreate(MainActivity.java:26)
07-17 22:46:49.281: E/AndroidRuntime(481): at android.app.Activity.performCreate(Activity.java:5231)
07-17 22:46:49.281: E/AndroidRuntime(481): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-17 22:46:49.281: E/AndroidRuntime(481): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
After googling and searching many questions on stackoverflow I found this and this but both snippets are used in activties .
How could I use such code in my app so that I can capture picture from background
You can use a dummy SurfaceTexture instead of a SurfaceView. This is reliable and works fine on the old camera API:
mDummyTexture = new SurfaceTexture(1); // pick a random argument for texture id
mCamera.setPreviewTexture(mDummyTexture);
mCamera.startPreview();
mCamera.takePicture(...);
Just make sure to keep mDummyTexture as a member of your class, or you may get abandoned surface errors.
As long as you don't call SurfaceTexture#updateTexImage(), you do not need an OpenGL context.
You shouldn't use a dummy SurfaceView as Android checks is the SurfaceView is displayed on the screen.
Instead, display the preview on a SurfaceView with WindowManager, with type SYSTEM_OVERLAY. Set your SurfaceView width and height to 1px and the opacity to 0 to hide the preview, and that's it!
If you plan to support only 5.0+ devices, or it's a new app that won't be available too soon, you should consider using the new android Camera2 API, which fixed many mistakes of the older API.
Hope it will help you :)
This is not possible, you need an activity to display the camera in.
Consider a transparent activity that just holds the camera view.
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I am working with OCR android. Got samples from googling and work with android tesseract. I have the project as library and refered in another project but, when I run the project it shows the following in Logcat
07-17 10:38:47.092: ERROR/AndroidRuntime(426): FATAL EXCEPTION: main
07-17 10:38:47.092: ERROR/AndroidRuntime(426): java.lang.ExceptionInInitializerError
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at com.imagetotext.ImagetoText.onCreate(ImagetoText.java:21)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at android.os.Handler.dispatchMessage(Handler.java:99)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at android.os.Looper.loop(Looper.java:123)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at java.lang.reflect.Method.invokeNative(Native Method)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at java.lang.reflect.Method.invoke(Method.java:521)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at dalvik.system.NativeStart.main(Native Method)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): Caused by: java.lang.UnsatisfiedLinkError: Library liblept not found
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at java.lang.Runtime.loadLibrary(Runtime.java:461)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at java.lang.System.loadLibrary(System.java:557)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): at com.googlecode.tesseract.android.TessBaseAPI.<clinit>(TessBaseAPI.java:47)
07-17 10:38:47.092: ERROR/AndroidRuntime(426): ... 14 more
07-17 10:38:47.112: WARN/ActivityManager(60): Force finishing activity com.imagetotext/.ImagetoText
I think there is something wrong with my android.mk. Please help me fix the error.
Exception cause line is,
System.loadLibrary(“lept”);
The problem is liblept.so (shared library) file can not found on specific library path. Without seeing your code just only assumption is your code trying to load shared library liblept.so and the library is not available at that path.
Also the code you are using is either have that liblept.so file in any lib or internal package directory or you have to generate (build) that shared library by using Android-NDK.
There can be several instances of the same Activity in the task. My problem is that when I declare header-fragment like this:
<fragment
android:name="fragments.TabletHeader"
android:layout_width="match_parent"
android:layout_height="56dp"
android:id="#+id/header" />
it stumbles on the second creation of the same activity. This is, I guess, because this static declaration forces system to create second insance of the same fragment which is not allowed. Am I right ?
What are the tactics for solving this issue. Essentially I need to switch to the dynamic approach but how do I find out whether fragment already exists. Show me some examples, please.
Here's the backtrace:
07-17 14:34:34.593: E/AndroidRuntime(15546): android.view.InflateException: Binary XML file line #7: Error inflating class fragment
07-17 14:34:34.593: E/AndroidRuntime(15546): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
07-17 14:34:34.593: E/AndroidRuntime(15546): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
07-17 14:34:34.593: E/AndroidRuntime(15546): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
07-17 14:34:34.593: E/AndroidRuntime(15546): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
07-17 14:34:34.593: E/AndroidRuntime(15546): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
07-17 14:34:34.593: E/AndroidRuntime(15546): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:273)
07-17 14:34:34.593: E/AndroidRuntime(15546): at android.app.Activity.setContentView(Activity.java:1835)
07-17 14:34:34.593: E/AndroidRuntime(15546): at android.activity.MainActivity$1.dispatchMessage(MainActivity.java:112)
07-17 14:34:34.593: E/AndroidRuntime(15546): at android.os.Looper.loop(Looper.java:137)
07-17 14:34:34.593: E/AndroidRuntime(15546): at android.app.ActivityThread.main(ActivityThread.java:4514)
07-17 14:34:34.593: E/AndroidRuntime(15546): at java.lang.reflect.Method.invokeNative(Native Method)
07-17 14:34:34.593: E/AndroidRuntime(15546): at java.lang.reflect.Method.invoke(Method.java:511)
07-17 14:34:34.593: E/AndroidRuntime(15546): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
07-17 14:34:34.593: E/AndroidRuntime(15546): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
07-17 14:34:34.593: E/AndroidRuntime(15546): at dalvik.system.NativeStart.main(Native Method)
07-17 14:34:34.593: E/AndroidRuntime(15546): Caused by: java.lang.IllegalArgumentException: Binary XML file line #7: Duplicate id 0x7f08000e, tag null, or parent id 0x0 with another fragment for android.fragments.TabletHeader
07-17 14:34:34.593: E/AndroidRuntime(15546): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:275)
07-17 14:34:34.593: E/AndroidRuntime(15546): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
07-17 14:34:34.593: E/AndroidRuntime(15546): ... 14 more
I have not been using fragments from XML, but have used the viewpager enough to see a lifetime of issues. One suggestion I can make for you to look into is the Tag that is set. I know the format of the tag when a FrameAdapter is used. When adding using a transaction, you can define your own tag. In the case of xml, I suspect that the Tag may be the Name parameter.
So, you can use the findFragmentByTag(String tag) function and try to use the value of the Name field. If this gives you a valid fragment, you are all set.
Hope this helps. Again, the answer is an assumption which you can try.
EDIT:Another option may be to look into findFragmentById(R.id.header)
When I launch my app I get the following errors in the log. Can you anyone decipher some of them for me, and give me a potential solution? I would be so grateful if you could as its proving very frustrating and I am new to Android development. I am using Eclipse SDK with an Android AVD at 1.6 SDK level.
Thanks..
07-17 11:05:57.046:
ERROR/AndroidRuntime(226): Uncaught
handler: thread main exiting due to
uncaught exception 07-17
11:05:57.056:
ERROR/AndroidRuntime(226):
java.lang.RuntimeException: Unable to
start activity
ComponentInfo{com.darius.android.distractions/com.darius.android.distractions.Distractions}:
java.lang.ClassCastException:
android.widget.FrameLayout 07-17
11:05:57.056:
ERROR/AndroidRuntime(226): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401)
07-17 11:05:57.056:
ERROR/AndroidRuntime(226): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
07-17 11:05:57.056:
ERROR/AndroidRuntime(226): at
android.app.ActivityThread.access$2100(ActivityThread.java:116)
07-17 11:05:57.056:
ERROR/AndroidRuntime(226): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
07-17 11:05:57.056:
ERROR/AndroidRuntime(226): at
android.os.Handler.dispatchMessage(Handler.java:99)
07-17 11:05:57.056:
ERROR/AndroidRuntime(226): at
android.os.Looper.loop(Looper.java:123)
07-17 11:05:57.056:
ERROR/AndroidRuntime(226): at
android.app.ActivityThread.main(ActivityThread.java:4203)
07-17 11:05:57.056:
ERROR/AndroidRuntime(226): at
java.lang.reflect.Method.invokeNative(Native
Method) 07-17 11:05:57.056:
ERROR/AndroidRuntime(226): at
java.lang.reflect.Method.invoke(Method.java:521)
07-17 11:05:57.056:
ERROR/AndroidRuntime(226): at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:791)
07-17 11:05:57.056:
ERROR/AndroidRuntime(226): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
07-17 11:05:57.056:
ERROR/AndroidRuntime(226): at
dalvik.system.NativeStart.main(Native
Method) 07-17 11:05:57.056:
ERROR/AndroidRuntime(226): Caused by:
java.lang.ClassCastException:
android.widget.FrameLayout 07-17
11:05:57.056:
ERROR/AndroidRuntime(226): at
com.darius.android.distractions.Distractions.onCreate(Distractions.java:87)
07-17 11:05:57.056:
ERROR/AndroidRuntime(226): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
07-17 11:05:57.056:
ERROR/AndroidRuntime(226): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
07-17 11:05:57.056:
ERROR/AndroidRuntime(226): ... 11
more
Your problem is on line 87 of your Distractions class.
The error stack complaining of a ClassCastException which is thrown when a program attempts to cast an object to a type with which it is not compatible.
It looks like you are trying to cast a FrameLayout as something it is not.
Good tip for decoding the error stack, look for the line that says Caused by: This line will give you a reason for the error and the line below will show you where the error is happening and will include a line reference so you can easily find the problem.