How to receive data from an Intent filter to an .apk file?

0

I am creating a package installer and I do not know how to get the intent in my activity to handle the .apk extension file.

I know I should add getIntent(); and getTipe(); . But how to receive the apri uri in my activity ?

I have already used the following code that worked well in showing the icon and the App version, but it only shows the version of my app.

Java code:

Intent intent = getIntent();
    Uri data = intent.getData();
    String path = data.getPath();

    // Icone do app funcionando OK
    try
    {
        Drawable d = getPackageManager().getApplicationIcon(getPackageName());
        Icone.setBackgroundDrawable(d);
    }
    catch (PackageManager.NameNotFoundException e)
    {
        e.printStackTrace();
        return;
    }

    //Versao do app Funcinando OK
    String versionName = "";
    try {
        versionName = getApplicationContext().getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), 0).versionName;
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }

    Versao.setText(versionName);

    }

Manifest permissions:

                                                           

Manifest activity:

            <intent-filter>
                <action
                    android:name="android.intent.action.VIEW"/>
                <action
                    android:name="android.intent.action.INSTALL_PACKAGE"/>
                <category
                    android:name="android.intent.category.DEFAULT"/>
                <data
                    android:scheme="file"/>
                <data
                    android:mimeType="application/vnd.android.package-archive"/>
            </intent-filter>
            <intent-filter>
                <action
                    android:name="android.intent.action.INSTALL_PACKAGE"/>
                <category
                    android:name="android.intent.category.DEFAULT"/>
                <data
                    android:scheme="file"/>
                <data
                    android:scheme="package"/>
            </intent-filter>
        </activity>

.

Finishing. I want to know how to handle the apk file to read the data from this sdcard app in my activity.

    
asked by anonymous 31.05.2018 / 13:30

0 answers