サードパーティのアプリケーションを使用せずに Android アプリ内で pdf を開く必要があるアプリケーションを作成しています。また、webview で自分の pdf を表示したくありません。
ジャワ:
public class MainActivity extends ListActivity{
public class First extends ListActivity {
String[] pdflist;
File[] imagelist;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
File images = Environment.getExternalStorageDirectory();
imagelist = images.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return ((name.endsWith(".pdf")));
}
});
pdflist = new String[imagelist.length];
for (int i = 0; i < imagelist.length; i++) {
pdflist[i] = imagelist[i].getName();
}
this.setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, pdflist));
}
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
String path = imagelist[(int) id].getAbsolutePath();
openPdfIntent(path);
}
private void openPdfIntent(String path) {
try {
final Intent intent = new Intent(First.this, Second.class);
intent.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME, path);
startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
}}
Second.java
public class Second extends PdfViewerActivity
{
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
}
public int getPreviousPageImageResource() {
return R.drawable.left_arrow;
}
public int getNextPageImageResource() {
return R.drawable.right_arrow;
}
public int getZoomInImageResource() {
return R.drawable.zoom_in;
}
public int getZoomOutImageResource() {
return R.drawable.zoom_out;
}
public int getPdfPasswordLayoutResource() {
return R.layout.pdf_file_password;
}
public int getPdfPageNumberResource() {
return R.layout.dialog_pagenumber;
}
public int getPdfPasswordEditField() {
return R.id.etPassword;
}
public int getPdfPasswordOkButton() {
return R.id.btOK;
}
public int getPdfPasswordExitButton() {
return R.id.btExit;
}
public int getPdfPageNumberEditField() {
return R.id.pagenum_edit;
}
}
Android menifest に second.java も追加しましたが、logcat に次のエラーが表示されます。
logcat :
02-12 09:23:50.408: E/ActivityThread(713): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d8b368 that was originally bound here
02-12 09:23:50.408: E/ActivityThread(713): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
02-12 09:23:50.408: E/ActivityThread(713): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
02-12 09:23:50.408: E/ActivityThread(713): at android.app.ContextImpl.bindService(ContextImpl.java:1418)
02-12 09:23:50.408: E/ActivityThread(713): at android.app.ContextImpl.bindService(ContextImpl.java:1407)
02-12 09:23:50.408: E/ActivityThread(713): at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
02-12 09:23:50.408: E/ActivityThread(713): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
02-12 09:23:50.408: E/ActivityThread(713): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
02-12 09:23:50.408: E/ActivityThread(713): at com.android.emailcommon.service.ServiceProxy.test(ServiceProxy.java:191)
02-12 09:23:50.408: E/ActivityThread(713): at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1850)
02-12 09:23:50.408: E/ActivityThread(713): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
02-12 09:23:50.408: E/ActivityThread(713): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
02-12 09:23:50.408: E/ActivityThread(713): at android.os.AsyncTask$2.call(AsyncTask.java:287)
02-12 09:23:50.408: E/ActivityThread(713): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
02-12 09:23:50.408: E/ActivityThread(713): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
02-12 09:23:50.408: E/ActivityThread(713): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
02-12 09:23:50.408: E/ActivityThread(713): at java.lang.Thread.run(Thread.java:856)
02-12 09:23:50.455: E/StrictMode(713): null
何か助けて??