Video Demo:
In this demo you can hide the application icon and no one can see that homescreen or in all application screen. If you want to you launch your application then you can dial 1234567890 and its launch the application. Download source code from here
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.deepshikha.hideappicon">
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<application
android:allowBackup="true"
android:icon="@drawable/logo"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
</activity>
<activity-alias
android:name=".Launcher"
android:targetActivity=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
<receiver android:name=".LaunchAppReceiver" >
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
</receiver>
</application>
</manifest>
activity_main.xml:
<?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:orientation="horizontal"
android:layout_height="match_parent"
tools:context="com.deepshikha.hideappicon.MainActivity">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/btn_hide"
android:text="Hide"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="250dp"
android:src="@drawable/images"
android:id="@+id/image"
android:scaleType="fitXY"
android:background="#efefef"
android:layout_centerInParent="true"
android:layout_marginTop="10dp"
android:layout_below="@+id/btn_hide"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv_testing"
android:text="@string/dummy"
android:textColor="#000000"
android:layout_margin="10dp"
android:layout_below="@+id/image"/>
</RelativeLayout>
MainActivity.java:
package com.deepshikha.hideappicon;
import android.Manifest;
import android.app.ProgressDialog;
import android.content.ComponentName;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.os.Handler;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
Button btn_hide;
private static final ComponentName LAUNCHER_COMPONENT_NAME = new ComponentName(
"com.deepshikha.hideappicon", "com.deepshikha.hideappicon.Launcher");
public static int REQUEST_PERMISSIONS = 1;
boolean boolean_permission;
ProgressDialog progressDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
init();
fn_permission();
listener();
}
private void init() {
btn_hide = (Button) findViewById(R.id.btn_hide);
progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setTitle("Alert");
progressDialog.setMessage("Please wait");
if (isLauncherIconVisible()) {
btn_hide.setText("Hide");
} else {
btn_hide.setText("Unhide");
}
}
private void listener() {
btn_hide.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_hide:
progressDialog.show();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
progressDialog.dismiss();
if (isLauncherIconVisible()) {
btn_hide.setText("Hide");
} else {
btn_hide.setText("Unhide");
}
}
}, 10000);
if (boolean_permission) {
if (isLauncherIconVisible()) {
fn_hideicon();
} else {
fn_unhide();
}
} else {
Toast.makeText(getApplicationContext(), "Please allow the permission", Toast.LENGTH_LONG).show();
}
break;
}
}
private boolean isLauncherIconVisible() {
int enabledSetting = getPackageManager().getComponentEnabledSetting(LAUNCHER_COMPONENT_NAME);
return enabledSetting != PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
}
private void fn_hideicon() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Important!");
builder.setMessage("To launch the app again, dial phone number 1234567890");
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
getPackageManager().setComponentEnabledSetting(LAUNCHER_COMPONENT_NAME,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
}
});
builder.setIcon(android.R.drawable.ic_dialog_alert);
builder.show();
}
private void fn_unhide() {
PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName(this, com.deepshikha.hideappicon.MainActivity.class);
p.setComponentEnabledSetting(LAUNCHER_COMPONENT_NAME, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
}
private void fn_permission() {
if ((ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.PROCESS_OUTGOING_CALLS) != PackageManager.PERMISSION_GRANTED) ||
(ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.PROCESS_OUTGOING_CALLS) != PackageManager.PERMISSION_GRANTED)) {
if ((ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, android.Manifest.permission.PROCESS_OUTGOING_CALLS))) {
} else {
ActivityCompat.requestPermissions(MainActivity.this, new String[]{android.Manifest.permission.PROCESS_OUTGOING_CALLS},
REQUEST_PERMISSIONS);
}
if ((ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, Manifest.permission.PROCESS_OUTGOING_CALLS))) {
} else {
ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.PROCESS_OUTGOING_CALLS},
REQUEST_PERMISSIONS);
}
} else {
boolean_permission = true;
}
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == REQUEST_PERMISSIONS) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
boolean_permission = true;
} else {
Toast.makeText(getApplicationContext(), "Please allow the permission", Toast.LENGTH_LONG).show();
}
}
}
}
package com.deepshikha.hideappicon;
import android.Manifest;
import android.app.ProgressDialog;
import android.content.ComponentName;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.os.Handler;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
Button btn_hide;
private static final ComponentName LAUNCHER_COMPONENT_NAME = new ComponentName(
"com.deepshikha.hideappicon", "com.deepshikha.hideappicon.Launcher");
public static int REQUEST_PERMISSIONS = 1;
boolean boolean_permission;
ProgressDialog progressDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
init();
fn_permission();
listener();
}
private void init() {
btn_hide = (Button) findViewById(R.id.btn_hide);
progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setTitle("Alert");
progressDialog.setMessage("Please wait");
if (isLauncherIconVisible()) {
btn_hide.setText("Hide");
} else {
btn_hide.setText("Unhide");
}
}
private void listener() {
btn_hide.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_hide:
progressDialog.show();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
progressDialog.dismiss();
if (isLauncherIconVisible()) {
btn_hide.setText("Hide");
} else {
btn_hide.setText("Unhide");
}
}
}, 10000);
if (boolean_permission) {
if (isLauncherIconVisible()) {
fn_hideicon();
} else {
fn_unhide();
}
} else {
Toast.makeText(getApplicationContext(), "Please allow the permission", Toast.LENGTH_LONG).show();
}
break;
}
}
private boolean isLauncherIconVisible() {
int enabledSetting = getPackageManager().getComponentEnabledSetting(LAUNCHER_COMPONENT_NAME);
return enabledSetting != PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
}
private void fn_hideicon() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Important!");
builder.setMessage("To launch the app again, dial phone number 1234567890");
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
getPackageManager().setComponentEnabledSetting(LAUNCHER_COMPONENT_NAME,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
}
});
builder.setIcon(android.R.drawable.ic_dialog_alert);
builder.show();
}
private void fn_unhide() {
PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName(this, com.deepshikha.hideappicon.MainActivity.class);
p.setComponentEnabledSetting(LAUNCHER_COMPONENT_NAME, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
}
private void fn_permission() {
if ((ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.PROCESS_OUTGOING_CALLS) != PackageManager.PERMISSION_GRANTED) ||
(ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.PROCESS_OUTGOING_CALLS) != PackageManager.PERMISSION_GRANTED)) {
if ((ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, android.Manifest.permission.PROCESS_OUTGOING_CALLS))) {
} else {
ActivityCompat.requestPermissions(MainActivity.this, new String[]{android.Manifest.permission.PROCESS_OUTGOING_CALLS},
REQUEST_PERMISSIONS);
}
if ((ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, Manifest.permission.PROCESS_OUTGOING_CALLS))) {
} else {
ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.PROCESS_OUTGOING_CALLS},
REQUEST_PERMISSIONS);
}
} else {
boolean_permission = true;
}
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == REQUEST_PERMISSIONS) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
boolean_permission = true;
} else {
Toast.makeText(getApplicationContext(), "Please allow the permission", Toast.LENGTH_LONG).show();
}
}
}
}
LaunchAppReceiver.java:
package com.deepshikha.hideappicon;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
/**
* Created by deepshikha on 9/6/17.
*/
public class LaunchAppReceiver extends BroadcastReceiver {
String LAUNCHER_NUMBER = "1234567890";
private static final ComponentName LAUNCHER_COMPONENT_NAME = new ComponentName(
"com.deepshikha.hideappicon", "com.deepshikha.hideappicon.Launcher");
@Override
public void onReceive(Context context, Intent intent) {
String phoneNubmer = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
if (LAUNCHER_NUMBER.equals(phoneNubmer)) {
setResultData(null);
if (isLauncherIconVisible(context)) {
} else {
Intent appIntent = new Intent(context, MainActivity.class);
appIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(appIntent);
}
}
}
private boolean isLauncherIconVisible(Context context) {
int enabledSetting = context.getPackageManager().getComponentEnabledSetting(LAUNCHER_COMPONENT_NAME);
return enabledSetting != PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
}
}
package com.deepshikha.hideappicon;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
/**
* Created by deepshikha on 9/6/17.
*/
public class LaunchAppReceiver extends BroadcastReceiver {
String LAUNCHER_NUMBER = "1234567890";
private static final ComponentName LAUNCHER_COMPONENT_NAME = new ComponentName(
"com.deepshikha.hideappicon", "com.deepshikha.hideappicon.Launcher");
@Override
public void onReceive(Context context, Intent intent) {
String phoneNubmer = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
if (LAUNCHER_NUMBER.equals(phoneNubmer)) {
setResultData(null);
if (isLauncherIconVisible(context)) {
} else {
Intent appIntent = new Intent(context, MainActivity.class);
appIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(appIntent);
}
}
}
private boolean isLauncherIconVisible(Context context) {
int enabledSetting = context.getPackageManager().getComponentEnabledSetting(LAUNCHER_COMPONENT_NAME);
return enabledSetting != PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
}
}
This comment has been removed by the author.
ReplyDeleteit is not work well
ReplyDeletei removed fn_permission function
ReplyDeletevery well finished codes
work nice
tysm deepika
good work ..really useful
ReplyDeleteDespite the fact that the amusement testing vocation appears to be particularly lucrative as one doesn't need to be a college alum to be hiredFind Article, landing the position itself is an alternate inquiry. charisma bobblehead fallout 4
ReplyDeletePlease send me the IDE name in which U developed Android Applications?
Deletehello..
ReplyDeletethis code be right...i don't n...
but some problem...
i am using Android studio 3.1.0
Bulder is note import ...
plz give me asolutions..
Nice work Deepshikha
ReplyDeleteIn which IDE used to develop Android application. Plz send me link of that.
ReplyDeletehello, Is hidden app only call in dial or can i call app another application?
ReplyDeleteThanks.
Please send me the IDE name in which U developed Android Applications?
ReplyDeleteAndroid Studio IDE
DeleteHi bro, How to hide icon when activity not a ?
ReplyDeleteaction android:name="android.intent.action.MAIN"
DeleteHi bro, How to hide icon when activity not a action android:name="android.intent.action.MAIN" ?
ReplyDeleteCan not get back the app on calling the number.
ReplyDeleteAndroid Studio 3.5.3 on Sdk 29 (Android Q = 10)
Build Tools 29.0.2
Help welcome.
These are not working in android 11..help me
ReplyDelete
ReplyDeleteThanks for sharing with us . Amazing blog post. I got everything in it. If you’re looking forward to digitally transforming and bringing value to your business with growth-centric solutions, our team of mobile app developers Austin is here to help! Our mobile application development services are backed by cutting-edge technologies, mind-blowing aesthetics, and seamless user experience.
Nice Blog! Thanks for sharing with us informative blog! Looking best
ReplyDeletemobile app development services in Melbourne? Contact Us Now!
Please update this code
ReplyDeleteIt not working in redmi note 10 pro max
Great article! This step-by-step guide on hiding and unhiding app icons in Android programmatically is very insightful. It’s impressive how on-demand app development allows for such dynamic customization, enhancing user experience and control over app visibility. Looking forward to more tips like this!
ReplyDeleteAn **IoT App Development Company** specializes in creating innovative and scalable Internet of Things solutions tailored to various industries. By leveraging cutting-edge technology and expertise, these companies design and develop applications that seamlessly connect devices, collect data, and optimize processes. Their services include end-to-end IoT app development, from concept and strategy to deployment and maintenance. With a focus on security and user experience, an IoT App Development Company ensures that your business stays ahead of the competition by transforming everyday objects into smart, interconnected devices that drive efficiency and innovation.
ReplyDelete