【发布时间】:2011-07-13 02:41:39
【问题描述】:
我正在尝试在我的 android 模拟器 (2.3.3) 上创建一个 pdf 打开器,但是每次我运行它时它都会返回一个 Activitynotfound 异常。我检查了包名和类名,它是正确的。我对 Android 开发也很陌生。这是代码!
公共类 PdfViewerActivity 扩展 Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tv = new TextView(this);
File file = new File("mnt/sdcard/proposal.pdf");
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri path2 = Uri.fromFile(file);
intent.setDataAndType(path2, "application/pdf");
try
{
startActivity(intent);
}
catch(ActivityNotFoundException e )
{
tv.setText("What the hell is going on O_O" + "\n" + e);
setContentView(tv);
}
}
}
===========
清单
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".PdfViewerActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
【问题讨论】:
标签: java android exception android-activity