Just open your main XML file and paste below code:
</LinearLayout>
Now open your java file and paste below code:
                        
            
 
Now run your code....
<LinearLayout xmlns:android="http://schemas.
    android:id="@+id/ll"
    android:layout_width="fill_
    android:layout_height="fill_
    android:orientation="vertical"
>
    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_
        android:layout_height="wrap_
        android:text="My BOOK" 
        android:onClick="book"/>
Now open your java file and paste below code:
package sel.listG; //package name
import java.io.File;
import
android.net.Uri;
import
android.os.Bundle;
import
android.view.View;
import
android.widget.Toast;
import
android.app.Activity;
import
android.content.
import
android.content.Intent;
public class MainActivity extends Activity 
{
      @Override
      protected void onCreate(Bundle
savedInstanceState) {
            super.onCreate(
            setContentView(R.layout.activi
      }
      public void book(View v)
      {
//your pdf file path 
            File
file=new File("/sdcard/anna.pdf");
            if(file.exists())
            {
                  Intent
i= new Intent(Intent.ACTION_VIEW);
//set pdf to doc if you want to open doc
                  i.setDataAndType(Uri.fromFile(
                  i.setFlags(Intent.FLAG_
                  try
                  {
                  startActivity(i);
                  }
                  catch(
                  {
//if pdf reader not found than open browser to download pdf reader 
                        Intent
i1=new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.
                        startActivity(i1);
                  }
            }
            else
            {
//if pdf not found on given location 
                  Toast.makeText(
            }
      }
}Now run your code....
 
 
  
 
 
 
 
hey please help me like this one is using sdcard open file but my one project in using inbuilt file like raw folder using open pdf file and only show this so how i m doing this task please help me and example send me
ReplyDeleteand ya please my mail id hardik.kacha@gmail.com
DeleteMay this link help you sir:-
Deletehttp://stackoverflow.com/questions/13517412/how-to-open-a-pdf-file-from-res-raw-folder
Sir can you give me code for edit ppt in my android application
ReplyDeleteHow to upload pdf file on the server
ReplyDeleteplease help me with my project which help to communicate b/w two devices and these devices must be able to share document with each other
ReplyDeletehi , its showing the message as can not open the document
ReplyDeleteNot sure what is wrong, used path as /sdcard/samplepdf.pdf still its shwos no document found message which is mentioned in the TOAST
Delete