Click here to Skip to main content
16,016,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.try">

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".pdfwatch" />
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
<activity android:name=".MainActivity3">
    <intent-filter android:scheme="http">
        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.DEFAULT" />


        <data android:mimeType="application/pdf" />
    </intent-filter>
        </activity>
    </application>


public class MainActivity3 extends AppCompatActivity {
    PDFView pdfviewer;
    PDFView pfc;

    private static final int REQUEST_CODE_STORAGE_PERMISSION =1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main3);
        pfc = (PDFView) findViewById(R.id.pdfView1);
    //    Intent intent = new Intent("android.intent.action.VIEW");
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        Uri contactUri = intent.getData();
        pfc.fromUri(contactUri).load();

    }


What I have tried:

i am trying to open the file directly by clicking the pdf file in my app to view but its not working but its not working . I know by listview method but i want to open it directly.please someone help.
Posted
Updated 4-Jul-20 10:42am
Comments
David Crow 4-Jul-20 15:46pm    
Is an Intent, with valid data, being passed to the MainActivity3 activity? If so, how are you verifying this?

What is the value of contactUri?

1 solution

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".WebViewActivity">

    <WebView
        android:id="@+id/webView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900