Advertisement

Hide app in android studio

How to hide the app in android studio ?



In this Video we will learn how can we hide the app in android studio using some codes
This is our Activity .xml code :-

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hide app" />
</RelativeLayout>
This Is our MainActivity.java code :-
 package com.example.hideapp;
import androidx.appcompat.app.AppCompatActivity;
import android.content.ComponentName;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {

Button bt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bt = findViewById(R.id.button);
bt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PackageManager packageManager = getPackageManager();
ComponentName componentName = new ComponentName(MainActivity.this,MainActivity.class);
packageManager.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
Toast.makeText(MainActivity.this, "App HiDEN", Toast.LENGTH_SHORT).show();
}
});
}
}























Post a Comment

0 Comments