I'm trying to create a pdf opener on my android emulator (2.3.3), however it is returning an Activitynotfound exception every time i run it. I've checked the package name and the class name and it is correct. I am also quite new in Android development. Here are the codes!
public class PdfViewerActivity extends 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);
}
}
}
==========
Manifest
<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>