1
votes

When I upload my app on play store there was give me error something like that Your app currently targets API level 29 and must target at least API level 30 to ensure that it is built on the latest APIs optimized for security and performance. then I will Change my target API Level 29 to 30 but when I run my app WhatsApp status are not visible and in logcat show something like permission denied..

Whatsapp_Saver.java

    int requestcode=1;
    Whatsapp_adapter adapter;
    File[]files;
    RecyclerView recyclerView;
    SwipeRefreshLayout swipeRefreshLayout;
    ArrayList<wp_model>filelist=new ArrayList<>();
    Toolbar toolbar;
    ImageView whatsapp_c;
    boolean isOpenWapp = false, isOpenWbApp = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_whatsapp_saver);
        toolbar=findViewById(R.id.whatsa_saver);
        whatsapp_c=findViewById(R.id.whatsapp_click);
        setSupportActionBar(toolbar);
        if (getSupportActionBar() != null){
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            getSupportActionBar().setDisplayShowHomeEnabled(true);
        }
        toolbar.setNavigationOnClickListener(view -> onBackPressed());
        recyclerView=findViewById(R.id.whatsapp_screen);
        swipeRefreshLayout=findViewById(R.id.swipe);


        setuplayout();
//        checkpermission();


        swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                swipeRefreshLayout.setRefreshing(true);
                setuplayout();
                {
                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            swipeRefreshLayout.setRefreshing(false);
                        }
                    },1000);
                }
            }

        });

        whatsapp_c.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    isOpenWapp = true;
                    startActivity(getPackageManager().getLaunchIntentForPackage("com.whatsapp"));
                } catch (Exception e) {
                    e.printStackTrace();
                    Toast.makeText(Whatsapp_saver.this, "Please Install WhatsApp  For Download Status!!!!!", Toast.LENGTH_SHORT).show();
                }

            }
        });
    }


    private void checkpermission() {
        if(SDK_INT>23){
            if(checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED){
                setuplayout();

            }
            else{
                ActivityCompat.requestPermissions(Whatsapp_saver.this,new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},requestcode);
            }
        }
        else {

            Toast.makeText(getApplicationContext(), "Already", Toast.LENGTH_SHORT).show();
            setuplayout();
        }

    }

    private void setuplayout() {
        filelist.clear();
        recyclerView.setHasFixedSize(true);
        StaggeredGridLayoutManager staggeredGridLayoutManager=new StaggeredGridLayoutManager(3,StaggeredGridLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(staggeredGridLayoutManager);
        adapter=new Whatsapp_adapter(Whatsapp_saver.this,getData());
        recyclerView.setAdapter(adapter);
        adapter.notifyDataSetChanged();
        
    }


    public File getWhatsupFolder() {
        if (new File(Environment.getExternalStorageDirectory() + File.separator + "Android/media/com.whatsapp/WhatsApp" + File.separator + "Media" + File.separator + ".Statuses").isDirectory()) {
            return new File(Environment.getExternalStorageDirectory() + File.separator + "Android/media/com.whatsapp/WhatsApp" + File.separator + "Media" + File.separator + ".Statuses");
        } else {
            return new File(Environment.getExternalStorageDirectory() + File.separator + "WhatsApp" + File.separator + "Media" + File.separator + ".Statuses");
        }
    }
    private ArrayList<wp_model> getData() {

        File whatswapp=getWhatsupFolder();
        wp_model wp_model;
//        String targetpath= Environment.getExternalStorageDirectory().getAbsolutePath()+ Constants.FOLDER_NAME+"Media/.Statuses";
//        String targetpath=Environment.getExternalStorageDirectory().getAbsolutePath()+"Android/media/com.whatsapp/WhatsApp/Media/.Statues";
//        File targetDirectory=new File(targetpath);
        files=whatswapp.listFiles();
        Arrays.sort(files, LastModifiedFileComparator.LASTMODIFIED_REVERSE);
        for(int i=0;i<files.length;i++){
            File file=files[i];
            wp_model=new wp_model();
            wp_model.setUri(Uri.fromFile(file));
            wp_model.setPath(files[i].getAbsolutePath());
            wp_model.setFilename(file.getName());
            if(!wp_model.getUri().toString().endsWith(".nomedia")){
                filelist.add(wp_model);
            }
        }
        return filelist;
    }

    @Override
    public void onBackPressed() {
        Intent intent=new Intent(getApplicationContext(),MainActivity.class);
        startActivity(intent);
        super.onBackPressed();
    }
}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.namelox.instagram.sparksallinonevideodownload">

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE"/>

    <application
        android:name="com.namelox.instagram.sparksallinonevideodownload.App"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:requestLegacyExternalStorage="true"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="false"
        android:theme="@style/facebook_theme_light"
        android:usesCleartextTraffic="true"
        tools:ignore="GoogleAppIndexingWarning">
        <activity
            android:name="com.namelox.instagram.sparksallinonevideodownload.activities.Youtube_saver"
            android:exported="true" />

        <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="${applicationId}.provider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_provider_paths" />
        </provider>

        <activity
            android:name="com.namelox.instagram.sparksallinonevideodownload.activities.picture"
            android:screenOrientation="portrait"
            android:exported="true" />
        <activity
            android:name="com.namelox.instagram.sparksallinonevideodownload.activities.video"
            android:screenOrientation="portrait"
            android:exported="true" />
        <activity
            android:name="com.namelox.instagram.sparksallinonevideodownload.activities.Whatsapp_saver"
            android:screenOrientation="portrait"
            android:exported="true" />
        <activity
            android:name="com.namelox.instagram.sparksallinonevideodownload.activities.SplashActivity"
            android:screenOrientation="portrait"
            android:theme="@style/AppThemeDark">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.namelox.instagram.sparksallinonevideodownload.activities.MainActivity"
            android:screenOrientation="portrait"
            android:theme="@style/facebook_theme_light"
            android:windowSoftInputMode="adjustPan|stateAlwaysHidden" />
        <activity
            android:name="com.namelox.instagram.sparksallinonevideodownload.activities.LoginActivity"
            android:screenOrientation="portrait"
            android:theme="@style/facebook_theme_light" />
        <activity
            android:name="com.namelox.instagram.sparksallinonevideodownload.activities.VideoPlayerActivity"
            android:screenOrientation="portrait"
            android:theme="@style/AppThemeDark" />
        <activity
            android:name="com.namelox.instagram.sparksallinonevideodownload.activities.StoriesFullViewActivity"
            android:screenOrientation="portrait"
            android:theme="@style/AppThemeDark" />
        <activity
            android:name="com.namelox.instagram.sparksallinonevideodownload.activities.PreviewActivity"
            android:screenOrientation="portrait"
            android:theme="@style/AppThemeDark" />

        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="@string/admob_app_id" />

        <service
            android:name="com.namelox.instagram.sparksallinonevideodownload.firebase.FireBaseNotification"
            android:enabled="true"
            android:exported="true">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>

        <meta-data
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@mipmap/ic_launcher_round" />
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_color"
            android:resource="@color/mainColor" />
    </application>

</manifest>

build.gradle

plugins {
    id 'com.onesignal.androidsdk.onesignal-gradle-plugin'
    id 'com.android.application'

}

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"
    defaultConfig {
        applicationId 'com.sparksallinonevideodownload'
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        setProperty("archivesBaseName", "Instagram Downloader")
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        ndk {
            abiFilters 'armeabi-v7a'
            abiFilters 'arm64-v8a'
            abiFilters 'x86'
        }
    }

    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }

    repositories {
        flatDir {
            dirs 'libs'
        }
        maven {
            url "https://jitpack.io"
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.7.1'
    implementation 'com.squareup.retrofit2:converter-gson:2.7.1'
    implementation 'com.squareup.retrofit2:retrofit:2.7.1'
    implementation 'com.squareup.okhttp3:okhttp:4.3.1'
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
    implementation 'com.squareup.okhttp3:logging-interceptor:4.3.1'
    implementation 'io.reactivex.rxjava2:rxjava:2.2.19'
    implementation 'com.onesignal:OneSignal:4.2.0'
    implementation 'com.github.bumptech.glide:glide:4.11.0'
    implementation 'com.google.android.play:core:1.10.0'
    //implementation 'com.anjlab.android.iab.v3:library:1.1.0'
    implementation 'com.google.android.gms:play-services-ads:19.6.0'
    implementation 'com.google.firebase:firebase-analytics:18.0.2'
    implementation 'com.google.firebase:firebase-messaging:21.0.1'
    implementation 'com.github.florent37:shapeofview:1.3.2'
    implementation 'com.amitshekhar.android:android-networking:1.0.2'
    implementation 'de.hdodenhof:circleimageview:3.1.0'
    implementation 'com.gauravk.bubblenavigation:bubblenavigation:1.0.7'

    implementation 'org.apache:apache:23'
    implementation 'commons-io:commons-io:2.9.0'
    implementation 'org.apache.commons:commons-lang3:3.5'

    implementation 'com.github.HaarigerHarald:android-youtubeExtractor:master-SNAPSHOT'
}

apply plugin: 'com.google.gms.google-services'