我在使用的类中有此代码ShareActionProvider
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
try
{
getMenuInflater().inflate(R.layout.menu, menu);
MenuItem item = menu.findItem(R.id.menu_item_share);
myShareActionProvider = (ShareActionProvider)item.getActionProvider();
myShareActionProvider.setShareHistoryFileName(
ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
myShareActionProvider.setShareIntent(createShareIntent());
return true;
}
catch ( Exception e )
{
}
return false;
}
This is the Android OS 2.3.6
坠机事故是这样说的
java.lang.NoSuchMethodError: android.view.MenuItem.getActionProvider
at com.marketing.AdvertisingActivity.onCreateOptionsMenu(AdvertisingActivity.java:183)
at android.app.Activity.onCreatePanelMenu(Activity.java:2194)
at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:360)
at com.android.internal.policy.impl.PhoneWindow.onKeyDownPanel(PhoneWindow.java:605)
at com.android.internal.policy.impl.PhoneWindow.onKeyDown(PhoneWindow.java:1259)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1717)
at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2607)
at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2582)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1914)
at android.os.Handler.dispatchMessage(Handler.java:130)
at android.os.Looper.loop(SourceFile:351)
at android.app.ActivityThread.main(ActivityThread.java:3814)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:538)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:659)
at dalvik.system.NativeStart.main(Native Method)
当应用程序在 try/catch 块内时,它怎么会崩溃?
谢谢!