Microsoft Windows Phone 8.1 support ends (13 Jul 2017)

Microsoft has ended support for Windows Phone 8.1

Questions about Android development and PDF

how to open a pdf file inside sdcard

More
IP: 192.168.0.71 11 years 4 months ago #7551 by asliyanage
I have a pdf file inside sdcard.I need to open that pdf file.I have below code now.
Code:
m_layout = (RelativeLayout) LayoutInflater.from(this).inflate(R.layout.reader, null); m_reader = (PDFReader) m_layout.findViewById(R.id.view); //m_doc.SetCache( sdDir.toString()+"/1.dat" ); m_reader.PDFOpen(doc,false, this); m_thumb = (PDFThumbView) m_layout.findViewById(R.id.thumbs); setContentView(m_layout);

can i used SetCache method to set the path of a pdf file in sdcars ?or is there any other way to set a path of a pdf file ?
More
IP: 192.168.0.71 11 years 4 months ago #7559 by radaee
plz using m_doc.Open(...);
m_doc.SetCache is used to editing document.
More
IP: 192.168.0.71 11 years 4 months ago - 11 years 4 months ago #7566 by asliyanage
Then how can i set the path of a pdf file ?I don't want user to select the pdf file.I have view pager in my application.I need to view a pdf file in each page of view pager.Those pdf has only one page.So i just need to view the pdf file in each fragment.So i need a way to open a pdf file inside each fragments?
Last edit: 11 years 4 months ago by Docrishav.
More
IP: 192.168.0.71 11 years 4 months ago - 11 years 4 months ago #7570 by asliyanage
I am using below code in my class.
Code:
package com.radaee.reader; import java.io.File; import com.radaee.pdf.Document; import com.radaee.pdf.Global; import com.radaee.pdf.Page.Annotation; import com.radaee.reader.PDFReader.PDFReaderListener; import com.radaee.util.PDFThumbView; import com.radaee.view.PDFVPage; import android.support.v7.app.ActionBarActivity; import android.app.Activity; import android.os.Bundle; import android.os.Environment; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.widget.RelativeLayout; public class MainActivity extends Activity implements PDFReaderListener { private RelativeLayout m_layout; private RelativeLayout mContentView; private PDFReader m_reader = null; private PDFThumbView m_thumb = null; private Document doc; private Document m_doc = new Document(); // public final static String PATH_SD_CARD = "/20141017/Prime/pdf_previews"; File sdDir = Environment.getExternalStorageDirectory(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setContentView(R.layout.activity_main); try { Global.Init(this); m_layout = (RelativeLayout) LayoutInflater.from(this).inflate(R.layout.reader, null); m_reader = (PDFReader) m_layout.findViewById(R.id.view); // m_doc.SetCache(sdDir.toString() + "/1.dat"); // m_doc. // m_reader.PDFOpen(doc, false, this); // m_thumb = (PDFThumbView) m_layout.findViewById(R.id.thumbs); // setContentView(m_layout); openDoc("/mnt/sdcard/pdf/1.pdf"); } catch (Exception e) { e.printStackTrace(); } } public void openDoc(String path) { m_doc.Close(); int ret = m_doc.Open(path, null); if (ret == 0) { // m_doc.SetCache( Global.tmp_path + "/temp.dat" ); m_reader.PDFOpen(m_doc, false, this); mContentView.removeAllViews(); mContentView.addView(m_layout); } } protected void onDestroy() { // m_vFiles.close(); /* * if( m_vFiles != null ) { m_vFiles.close(); m_vFiles = null; } */ if (m_thumb != null) { m_thumb.thumbClose(); m_thumb = null; } if (m_reader != null) m_reader.PDFClose(); if (m_doc != null) m_doc.Close(); Global.RemoveTmp(); super.onDestroy(); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Override public void OnPageModified(int pageno) { // TODO Auto-generated method stub } @Override public void OnPageChanged(int pageno) { // TODO Auto-generated method stub } @Override public void OnAnnotClicked(PDFVPage vpage, Annotation annot) { // TODO Auto-generated method stub } @Override public void OnSelectEnd(String text) { // TODO Auto-generated method stub } @Override public void OnOpenURI(String uri) { // TODO Auto-generated method stub } @Override public void OnOpenJS(String js) { // TODO Auto-generated method stub } @Override public void OnOpenMovie(String path) { // TODO Auto-generated method stub } @Override public void OnOpenSound(int[] paras, String path) { // TODO Auto-generated method stub } @Override public void OnOpenAttachment(String path) { // TODO Auto-generated method stub } @Override public void OnOpen3D(String path) { // TODO Auto-generated method stub } }
when i run this i get below exception
Code:
10-28 13:44:39.790: A/libc(7264): Fatal signal 4 (SIGILL) at 0x5baa0fe2 (code=1)
I debug and the found below lines give me that error.
Global.Init(this);

If i comment the Init method it gives me below error.
Code:
10-28 14:40:33.831: W/dalvikvm(4390): No implementation found for native Lcom/radaee/pdf/Document;.open:(Ljava/lang/String;Ljava/lang/String;)I 10-28 14:40:33.831: D/AndroidRuntime(4390): Shutting down VM 10-28 14:40:33.831: W/dalvikvm(4390): threadid=1: thread exiting with uncaught exception (group=0x4184cda0) 10-28 14:40:33.831: E/AndroidRuntime(4390): FATAL EXCEPTION: main 10-28 14:40:33.831: E/AndroidRuntime(4390): Process: com.radaee.reader, PID: 4390 10-28 14:40:33.831: E/AndroidRuntime(4390): java.lang.UnsatisfiedLinkError: Native method not found: com.radaee.pdf.Document.open:(Ljava/lang/String;Ljava/lang/String;)I 10-28 14:40:33.831: E/AndroidRuntime(4390): at com.radaee.pdf.Document.open(Native Method) 10-28 14:40:33.831: E/AndroidRuntime(4390): at com.radaee.pdf.Document.Open(Document.java:417) 10-28 14:40:33.831: E/AndroidRuntime(4390): at com.radaee.reader.MainActivity.openDoc(MainActivity.java:58) 10-28 14:40:33.831: E/AndroidRuntime(4390): at com.radaee.reader.MainActivity.onCreate(MainActivity.java:46) 10-28 14:40:33.831: E/AndroidRuntime(4390): at android.app.Activity.performCreate(Activity.java:5600) 10-28 14:40:33.831: E/AndroidRuntime(4390): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093) 10-28 14:40:33.831: E/AndroidRuntime(4390): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2504) 10-28 14:40:33.831: E/AndroidRuntime(4390): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2599) 10-28 14:40:33.831: E/AndroidRuntime(4390): at android.app.ActivityThread.access$900(ActivityThread.java:174) 10-28 14:40:33.831: E/AndroidRuntime(4390): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321) 10-28 14:40:33.831: E/AndroidRuntime(4390): at android.os.Handler.dispatchMessage(Handler.java:102) 10-28 14:40:33.831: E/AndroidRuntime(4390): at android.os.Looper.loop(Looper.java:146) 10-28 14:40:33.831: E/AndroidRuntime(4390): at android.app.ActivityThread.main(ActivityThread.java:5748) 10-28 14:40:33.831: E/AndroidRuntime(4390): at java.lang.reflect.Method.invokeNative(Native Method) 10-28 14:40:33.831: E/AndroidRuntime(4390): at java.lang.reflect.Method.invoke(Method.java:515) 10-28 14:40:33.831: E/AndroidRuntime(4390): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291) 10-28 14:40:33.831: E/AndroidRuntime(4390): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107) 10-28 14:40:33.831: E/AndroidRuntime(4390): at dalvik.system.NativeStart.main(Native Method)
Last edit: 11 years 4 months ago by Docrishav.
More
IP: 192.168.0.158 11 years 4 months ago #7573 by nermeen
This error means that the native lib is missing, make sure to copy the libs directory into your project.
Time to create page: 0.424 seconds
Powered by Kunena Forum