I want to set ActionbarOverlay feature from within my SherlockFragment class.
Can any one please tell me, how can I do this?
I've tried by adding line getSherlockActivity().requestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY); in OnCreateView method.
But it gives me Error:
04-17 12:19:35.789: E/AndroidRuntime(844): FATAL EXCEPTION: main
04-17 12:19:35.789: E/AndroidRuntime(844): android.util.AndroidRuntimeException: requestFeature() must be called before adding content
04-17 12:19:35.789: E/AndroidRuntime(844): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:210)
04-17 12:19:35.789: E/AndroidRuntime(844): at com.oceans.sherelock.internal.ActionBarSherlockNative.requestFeature(ActionBarSherlockNative.java:97)
04-17 12:19:35.789: E/AndroidRuntime(844): at com.oceans.sherelock.app.SherlockFragmentActivity.requestWindowFeature(SherlockFragmentActivity.java:276)
04-17 12:19:35.789: E/AndroidRuntime(844): at com.wallpapermaker.keepcalm.UserProfile_NoBoringFragment.onCreateView(UserProfile_NoBoringFragment.java:92)
04-17 12:19:35.789: E/AndroidRuntime(844): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500)
04-17 12:19:35.789: E/AndroidRuntime(844): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:938)
04-17 12:19:35.789: E/AndroidRuntime(844): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1115)
04-17 12:19:35.789: E/AndroidRuntime(844): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
04-17 12:19:35.789: E/AndroidRuntime(844): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1478)
04-17 12:19:35.789: E/AndroidRuntime(844): at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:446)
04-17 12:19:35.789: E/AndroidRuntime(844): at android.os.Handler.handleCallback(Handler.java:605)
04-17 12:19:35.789: E/AndroidRuntime(844): at android.os.Handler.dispatchMessage(Handler.java:92)
04-17 12:19:35.789: E/AndroidRuntime(844): at android.os.Looper.loop(Looper.java:137)
04-17 12:19:35.789: E/AndroidRuntime(844): at android.app.ActivityThread.main(ActivityThread.java:4424)
04-17 12:19:35.789: E/AndroidRuntime(844): at java.lang.reflect.Method.invokeNative(Native Method)
04-17 12:19:35.789: E/AndroidRuntime(844): at java.lang.reflect.Method.invoke(Method.java:511)
04-17 12:19:35.789: E/AndroidRuntime(844): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-17 12:19:35.789: E/AndroidRuntime(844): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-17 12:19:35.789: E/AndroidRuntime(844): at dalvik.system.NativeStart.main(Native Method)
P.S. I can't set it from within Activity because I don't want overlay feature to be enabled for other Fragments in my Activity.
You Must Call before setContent called in your activity
getSherlockActivity().requestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY);
put this before adding content view in your activity.
i hope it helps.
UPDATE
then extends first SherlockFragment in your Fragment
then put code in OnCreate method of Activity before calling setContentView method.
getSherlock().requestFeature(Window.FEATURE_ACTION_MODE_OVERLAY);
sorry my fault
check update again.
Related
Sometime a received report from my user about this crash issue.
I cannot reproduce it with my device. It happen at the first time launch app and this is the stack trace from crash reporter:
Fatal Exception: java.lang.RuntimeException: Unable to resume activity {com.my.app.package.name/com.my.app.package.name.activity.Dispatcher}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=65538, result=0, data=null} to activity {com.my.app.package.name/com.my.app.package.name.activity.Dispatcher}: java.lang.NullPointerException
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2613)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2641)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2127)
at android.app.ActivityThread.access$600(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4895)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=65538, result=0, data=null} to activity {com.my.app.package.name/com.my.app.package.name.activity.Dispatcher}: java.lang.NullPointerException
at android.app.ActivityThread.deliverResults(ActivityThread.java:3179)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2600)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2641)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2127)
at android.app.ActivityThread.access$600(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4895)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by java.lang.NullPointerException
at com.google.android.gms.internal.zznu.onCreate(Unknown Source)
at com.google.android.gms.internal.zzpc.onActivityResult(Unknown Source)
at android.support.v4.app.FragmentActivity.onActivityResult(FragmentActivity.java:175)
at android.app.Activity.dispatchActivityResult(Activity.java:5347)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3175)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2600)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2641)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2127)
at android.app.ActivityThread.access$600(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4895)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
at dalvik.system.NativeStart.main(NativeStart.java)
Any one can help me with this?
i want to have barcode scanner on my android application.I try to follow intruction from this Using ZXing to create an android barcode scanning app and looking good because i've barcodeScanner app being installed on my phone that i wasnt realize before. when i try to another phone when i want to scan barcode it ask me to download barcodeScanner. my issue is like this thread Embed Zxing library without using Barcode Scanner app and follow instruction.but i got an error in this line super.onResume();.here is my error logcat
04-17 16:00:51.735: E/AndroidRuntime(6138): FATAL EXCEPTION: main
04-17 16:00:51.735: E/AndroidRuntime(6138): java.lang.RuntimeException: Unable to resume activity {ims.app.salesmarket/ims.app.salesmarket.EntryTO}: java.lang.NullPointerException
04-17 16:00:51.735: E/AndroidRuntime(6138): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2595)
04-17 16:00:51.735: E/AndroidRuntime(6138): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2623)
04-17 16:00:51.735: E/AndroidRuntime(6138): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2109)
04-17 16:00:51.735: E/AndroidRuntime(6138): at android.app.ActivityThread.access$600(ActivityThread.java:134)
04-17 16:00:51.735: E/AndroidRuntime(6138): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
04-17 16:00:51.735: E/AndroidRuntime(6138): at android.os.Handler.dispatchMessage(Handler.java:99)
04-17 16:00:51.735: E/AndroidRuntime(6138): at android.os.Looper.loop(Looper.java:154)
04-17 16:00:51.735: E/AndroidRuntime(6138): at android.app.ActivityThread.main(ActivityThread.java:4624)
04-17 16:00:51.735: E/AndroidRuntime(6138): at java.lang.reflect.Method.invokeNative(Native Method)
04-17 16:00:51.735: E/AndroidRuntime(6138): at java.lang.reflect.Method.invoke(Method.java:511)
04-17 16:00:51.735: E/AndroidRuntime(6138): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
04-17 16:00:51.735: E/AndroidRuntime(6138): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
04-17 16:00:51.735: E/AndroidRuntime(6138): at dalvik.system.NativeStart.main(Native Method)
04-17 16:00:51.735: E/AndroidRuntime(6138): Caused by: java.lang.NullPointerException
04-17 16:00:51.735: E/AndroidRuntime(6138): at com.google.zxing.client.android.CaptureActivity.onResume(CaptureActivity.java:163)
04-17 16:00:51.735: E/AndroidRuntime(6138): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1159)
04-17 16:00:51.735: E/AndroidRuntime(6138): at android.app.Activity.performResume(Activity.java:4553)
04-17 16:00:51.735: E/AndroidRuntime(6138): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2581)
04-17 16:00:51.735: E/AndroidRuntime(6138): ... 12 more
how do i fix them?
every help will be apriciated.thank you for your kindness.
I had faced the same problem. I tried to fix it by a couple of ways, and both of them eventually worked!!
Go to onResume() at CaptureActivity.java. Comment the whole function except the line super.onResume(). Next, add the following lines into your activity:
#Override
public void onResume(){
super.onResume();
}
You could use the example from this link - http://khurramitdeveloper.blogspot.in/p/android-barcode-scan-using-zxing-library.html. It works for me without any hitch!
I'm trying to implement PagerSlidingTabStrip in my app. I did everything I'm supposed to do:
Added it to my XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.astuetz.PagerSlidingTabStrip
android:id="#+id/slidingTabs"
android:layout_width="match_parent"
android:layout_height="48dip" />
</RelativeLayout>
Created PagerSlidingTabStrip and tried to set ViewPager:
PagerSlidingTabStrip slidingTabStrip = (PagerSlidingTabStrip) findViewById(R.id.slidingTabs);
slidingTabStrip.setViewPager(vPager);
But when I run the app, it crashes and this is the logcat output:
04-17 20:56:55.956: E/AndroidRuntime(1587): FATAL EXCEPTION: main
04-17 20:56:55.956: E/AndroidRuntime(1587): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.matejhacin.beautifulvoicerecorder/com.matejhacin.beautifulvoicerecorder.MainActivity}: java.lang.NullPointerException
04-17 20:56:55.956: E/AndroidRuntime(1587): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
04-17 20:56:55.956: E/AndroidRuntime(1587): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
04-17 20:56:55.956: E/AndroidRuntime(1587): at android.app.ActivityThread.access$600(ActivityThread.java:141)
04-17 20:56:55.956: E/AndroidRuntime(1587): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
04-17 20:56:55.956: E/AndroidRuntime(1587): at android.os.Handler.dispatchMessage(Handler.java:99)
04-17 20:56:55.956: E/AndroidRuntime(1587): at android.os.Looper.loop(Looper.java:137)
04-17 20:56:55.956: E/AndroidRuntime(1587): at android.app.ActivityThread.main(ActivityThread.java:5103)
04-17 20:56:55.956: E/AndroidRuntime(1587): at java.lang.reflect.Method.invokeNative(Native Method)
04-17 20:56:55.956: E/AndroidRuntime(1587): at java.lang.reflect.Method.invoke(Method.java:525)
04-17 20:56:55.956: E/AndroidRuntime(1587): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
04-17 20:56:55.956: E/AndroidRuntime(1587): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
04-17 20:56:55.956: E/AndroidRuntime(1587): at dalvik.system.NativeStart.main(Native Method)
04-17 20:56:55.956: E/AndroidRuntime(1587): Caused by: java.lang.NullPointerException
04-17 20:56:55.956: E/AndroidRuntime(1587): at com.astuetz.PagerSlidingTabStrip.notifyDataSetChanged(PagerSlidingTabStrip.java:200)
04-17 20:56:55.956: E/AndroidRuntime(1587): at com.astuetz.PagerSlidingTabStrip.setViewPager(PagerSlidingTabStrip.java:182)
04-17 20:56:55.956: E/AndroidRuntime(1587): at com.matejhacin.beautifulvoicerecorder.MainActivity.onCreate(MainActivity.java:39)
04-17 20:56:55.956: E/AndroidRuntime(1587): at android.app.Activity.performCreate(Activity.java:5133)
04-17 20:56:55.956: E/AndroidRuntime(1587): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
04-17 20:56:55.956: E/AndroidRuntime(1587): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
The error isn't handled nicely in this library. If you look at the source of PagerAdapter you will see a method getPageTitle:
https://github.com/android/platform_frameworks_support/blob/master/v4/java/android/support/v4/view/PagerAdapter.java#L306-Lundefined
Notice that by default it returns null. This is why you are seeing a null pointer exception. The solution is to override this method in your implementation of PagerAdapter
#Override
public CharSequence getPageTitle(int position) {
// return the title of the tab
}
If you don't actually want a string title, and you want the tab to use a custom view, such as an image, then your PagerAdapter has to implement PagerSlidingTabStrip.TabCustomViewProvider and override getPageTabCustomView
#Override
public View getPageTabCustomView(int position) {
// return a custom view
}
EDIT: In order to use the custom tab view, you will need to use this fork:
https://github.com/astuetz/PagerSlidingTabStrip/pull/32
Caused by: java.lang.NullPointerException
at com.astuetz.PagerSlidingTabStrip.notifyDataSetChanged(PagerSlidingTabStrip.java:200)
You're throwing a NullPointerException on line 200 in PagerSlidingTabStrip.
This indicates that PagerAdapter.getPageTitle is returning null.
You should override your adapters getPageTitle method because it is returning null
#Override
public CharSequence getPageTitle(int position)
{
return tabTitles[position];
}
I having abit of problem here as when i saw somewhere with calculator codes and use it somehow the app always force close when i started keying in numbers. help?
public void onClickListener8(View v)
{
vibrator.vibrate(30);
if(press=='=')
{
onClickListenerReset(buttonClear);
}
eight=(String)button8.getText();
sum=sum+eight;
editText.setText(sum);
}
04-17 15:38:23.110: E/AndroidRuntime(678): FATAL EXCEPTION: main
04-17 15:38:23.110: E/AndroidRuntime(678): java.lang.IllegalStateException: Could not execute method of the activity
04-17 15:38:23.110: E/AndroidRuntime(678): at android.view.View$1.onClick(View.java:2144)
04-17 15:38:23.110: E/AndroidRuntime(678): at android.view.View.performClick(View.java:2485)
04-17 15:38:23.110: E/AndroidRuntime(678): at android.view.View$PerformClick.run(View.java:9080)
04-17 15:38:23.110: E/AndroidRuntime(678): at android.os.Handler.handleCallback(Handler.java:587)
04-17 15:38:23.110: E/AndroidRuntime(678): at android.os.Handler.dispatchMessage(Handler.java:92)
04-17 15:38:23.110: E/AndroidRuntime(678): at android.os.Looper.loop(Looper.java:123)
04-17 15:38:23.110: E/AndroidRuntime(678): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-17 15:38:23.110: E/AndroidRuntime(678): at java.lang.reflect.Method.invokeNative(Native Method)
04-17 15:38:23.110: E/AndroidRuntime(678): at java.lang.reflect.Method.invoke(Method.java:507)
04-17 15:38:23.110: E/AndroidRuntime(678): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-17 15:38:23.110: E/AndroidRuntime(678): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-17 15:38:23.110: E/AndroidRuntime(678): at dalvik.system.NativeStart.main(Native Method)
04-17 15:38:23.110: E/AndroidRuntime(678): Caused by: java.lang.reflect.InvocationTargetException
04-17 15:38:23.110: E/AndroidRuntime(678): at java.lang.reflect.Method.invokeNative(Native Method)
04-17 15:38:23.110: E/AndroidRuntime(678): at java.lang.reflect.Method.invoke(Method.java:507)
04-17 15:38:23.110: E/AndroidRuntime(678): at android.view.View$1.onClick(View.java:2139)
04-17 15:38:23.110: E/AndroidRuntime(678): ... 11 more
04-17 15:38:23.110: E/AndroidRuntime(678): Caused by: java.lang.SecurityException: Requires VIBRATE permission
04-17 15:38:23.110: E/AndroidRuntime(678): at android.os.Parcel.readException(Parcel.java:1322)
04-17 15:38:23.110: E/AndroidRuntime(678): at android.os.Parcel.readException(Parcel.java:1276)
04-17 15:38:23.110: E/AndroidRuntime(678): at android.os.IVibratorService$Stub$Proxy.vibrate(IVibratorService.java:106)
04-17 15:38:23.110: E/AndroidRuntime(678): at android.os.Vibrator.vibrate(Vibrator.java:52)
04-17 15:38:23.110: E/AndroidRuntime(678): at com.mypackage.Calculator.onClickListener8(Calculator.java:232)
04-17 15:38:23.110: E/AndroidRuntime(678): ... 14 more
Make sure your app has the Vibrate permission. The following line should be there in the manifest:
<uses-permission android:name="android.permission.VIBRATE"/>
I think you must be using an emulator. Just comment out the vibrate; somehow that's the cause of the issue.
just included as first lines in my code to load different system libraries:
public class MyWebTestActivity extends Activity {
static {
System.loadLibrary("ui");
System.loadLibrary("android");
System.loadLibrary("chromium_net"); // - fails UnsatisfiedLinkError: unknown failure
}
...etc..
Stack trace:
04-17 14:04:23.121: W/dalvikvm(5041): Shared lib '/system/lib/libchromium_net.so' already opened by CL 0x0; can't open in 0x2bb4b9f0
04-17 14:04:23.121: W/dalvikvm(5041): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lmywebtest/MyWebTestActivity;
04-17 14:04:23.121: W/dalvikvm(5041): Class init failed in newInstance call (Lmywebtest/MyWebTestActivity;)
04-17 14:04:23.121: D/AndroidRuntime(5041): Shutting down VM
04-17 14:04:23.121: W/dalvikvm(5041): threadid=1: thread exiting with uncaught exception (group=0x2b4d61f8)
04-17 14:04:23.121: E/AndroidRuntime(5041): FATAL EXCEPTION: main
04-17 14:04:23.121: E/AndroidRuntime(5041): java.lang.ExceptionInInitializerError
04-17 14:04:23.121: E/AndroidRuntime(5041): at java.lang.Class.newInstanceImpl(Native Method)
04-17 14:04:23.121: E/AndroidRuntime(5041): at java.lang.Class.newInstance(Class.java:1319)
04-17 14:04:23.121: E/AndroidRuntime(5041): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
04-17 14:04:23.121: E/AndroidRuntime(5041): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
04-17 14:04:23.121: E/AndroidRuntime(5041): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
04-17 14:04:23.121: E/AndroidRuntime(5041): at android.app.ActivityThread.access$600(ActivityThread.java:123)
04-17 14:04:23.121: E/AndroidRuntime(5041): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
04-17 14:04:23.121: E/AndroidRuntime(5041): at android.os.Handler.dispatchMessage(Handler.java:99)
04-17 14:04:23.121: E/AndroidRuntime(5041): at android.os.Looper.loop(Looper.java:137)
04-17 14:04:23.121: E/AndroidRuntime(5041): at android.app.ActivityThread.main(ActivityThread.java:4424)
04-17 14:04:23.121: E/AndroidRuntime(5041): at java.lang.reflect.Method.invokeNative(Native Method)
04-17 14:04:23.121: E/AndroidRuntime(5041): at java.lang.reflect.Method.invoke(Method.java:511)
04-17 14:04:23.121: E/AndroidRuntime(5041): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
04-17 14:04:23.121: E/AndroidRuntime(5041): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
04-17 14:04:23.121: E/AndroidRuntime(5041): at dalvik.system.NativeStart.main(Native Method)
04-17 14:04:23.121: E/AndroidRuntime(5041): Caused by: java.lang.UnsatisfiedLinkError: unknown failure
04-17 14:04:23.121: E/AndroidRuntime(5041): at java.lang.Runtime.load(Runtime.java:340)
04-17 14:04:23.121: E/AndroidRuntime(5041): at java.lang.System.load(System.java:521)
04-17 14:04:23.121: E/AndroidRuntime(5041): at mytest.MyWebTestActivity.<clinit>(MyWebTestActivity.java:24)
Question: What does it mean "Shared lib [name] already opened by CL.."? How to fix it?
P.S. I have tried other system libraries to load (e.g. android -/system/lib/libandroid.so, ..audioalsa, camera_client, etc) all of them loads without a problem.
I run a rooted Xperia phone with Android 4.0.3. All libraries are present on the phone.