-인텐트를 이용하여 다른 어플리케이션을 호출하기 전 패키지 매니저를 이용하여 사용이 가능한지 체크 할 수 있다.
[sourcecode language="java"]
public static final String MIME_TYPE_PDF = "application/pdf";
public static boolean isIntentAvailable(Context context, String action) {
final PackageManager packageManager = context.getPackageManager();
final Intent intent = new Intent(action);
intent.setType(MIME_TYPE_PDF);
List list =
packageManager.queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);
return list.size() > 0;
}
[/sourcecode]
출처 : http://stackoverflow.com/questions/2784847/how-do-i-determine-if-android-can-handle-pdf
- PDF 뷰어 콜하기 위한 코드.
[sourcecode language="java"]
File file = new File("/sdcard/aaa.pdf");
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri uri = Uri.fromFile(file);
intent.setDataAndType(uri, "application/pdf");
startActivity(intent);
[/sourcecode]
출처 : http://stackoverflow.com/questions/2883355/how-to-render-pdf-in-android
[sourcecode language="java"]
public class OpenPdf extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button = (Button) findViewById(R.id.OpenPdfButton);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
File file = new File("/sdcard/example.pdf");
if (file.exists()) {
Uri path = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
startActivity(intent);
}
catch (ActivityNotFoundException e) {
Toast.makeText(OpenPdf.this,
"No Application Available to View PDF",
Toast.LENGTH_SHORT).show();
}
}
}
});
}
}
[/sourcecode]
- PDF Viewer (GUN License) -T-
Android PDF Viewer - http://code.google.com/p/apv/
VuDroid - http://code.google.com/p/vudroid/
APDFViewer - http://code.google.com/p/apdfviewer/
droidreader - http://code.google.com/p/droidreader/
android-pdf - http://code.google.com/p/android-pdf/