I want an application that is not in my phone to be checked for the name and to send the toast message accordingly. For example ; I have the Twitter app on my phone, but the ABC app is not on my phone. By entering a value in the string, the application will be written in the name and there will be no such application for the application to be. how can I do that? For example, I do not have ABC application on my phone and I do not have such an application with toast. I need to listen to the processes on the phone for this, but can I listen? I wrote something about the Services in the code I wrote below, but it is not complete. Should I look at ActivityManager or getRunningProcess for this? I hope I can tell.
MainActivity.java
public class MainActivity extends Activity {
String msg = "Twitter : ";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d(msg, "The onCreate() event");
}
public void startService(View view) {
startService(new Intent(getBaseContext(), MyService.class));
}
// Method to stop the service
public void stopService(View view) {
stopService(new Intent(getBaseContext(), MyService.class));
}
}
MyService.java
public class MyService extends Service {
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// Let it continue running until it is stopped.
Toast.makeText(this, "Service Started", Toast.LENGTH_LONG).show();
return START_STICKY;
}
@Override
public void onDestroy() {
super.onDestroy();
Toast.makeText(this, "Service Destroyed", Toast.LENGTH_LONG).show();
}
}