gpt4 book ai didi

java - Android Activitynotfound 错误?

转载 作者:行者123 更新时间:2023-12-01 15:48:19 25 4
gpt4 key购买 nike

我试图在我的 android 模拟器 (2.3.3) 上创建一个 pdf opener,但是每次运行它时它都会返回 Activitynotfound 异常。我检查了包名和类名,它是正确的。我对 Android 开发也很陌生。这是代码!

公共(public)类 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);
}


}

}

==========

list

<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>

最佳答案

您的手机上没有安装 PDF 查看器应用程序。这就是这里的启动 Activity 代码失败的原因。 PDF 打开器到底是什么意思?

关于java - Android Activitynotfound 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6673507/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com