I have successfully called third party apps from my app
Apps like: Google Drive and Google Photos
Code:
btnL1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
     openApp(KioskActivity.this, "com.google.android.apps.docs");
   }
});
btnL2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
     openApp(KioskActivity.this, "com.google.android.apps.photos");
    }
});
public static boolean openApp(Context context, String packageName) {
        PackageManager manager = context.getPackageManager();
        try {
            Intent i = manager.getLaunchIntentForPackage(packageName);
            if (i == null) {
                return false;
                //throw new PackageManager.NameNotFoundException();
            }
            i.addCategory(Intent.CATEGORY_LAUNCHER);
            context.startActivity(i);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
UPDATE # 1 Here is the Code I have followed to call third party app Activity from own App
On button click calling Activity of third party app (Like: Last FM)
final Intent intentDeviceTest = new Intent("android.intent.action.MAIN");                
intentDeviceTest.setComponent(new ComponentName("fm.last.android","fm.last.android.LastFm"));
startActivity(intentDeviceTest);
But always getting android.content.ActivityNotFoundException: Unable to find explicit activity class {fm.last.android/fm.last.android.LastFm}; have you declared this activity in your AndroidManifest.xml? And If I use try-catch blog or if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } to avoid ANF exception then its not showing exception, but still unable to call an activity
I already installed Last FM app on my device, so what could be the reason ?
UPDATE # 2 : I have created Hello World app and successfully called that one
Screenshots
Screenshot 1 (just enabled Kiosk Mode)
Screenshot 2 (just called Hello World app and pressed back to exit Hello World)
Question: Why it showing Navigation Bar and Bottom Bar (I mean Back, Home and Recents keys)
Here is my updated code:
  public class KioskActivity extends Activity {        
    final int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_FULLSCREEN
            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().getDecorView().setSystemUiVisibility(flags);
        getActionBar().hide();
        setContentView(wenchao.kiosk.R.layout.activity_lock_activity);
        DevicePolicyManager myDevicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
        ComponentName mDPM = new ComponentName(this, MyAdmin.class);
        if (myDevicePolicyManager.isDeviceOwnerApp(this.getPackageName())) {
            String[] packages = {this.getPackageName()};
            startLockTask();
        } else {
            Toast.makeText(getApplicationContext(),"Not owner", Toast.LENGTH_LONG).show();
        }
        setVolumMax();
        Button lock_btn = (Button)findViewById(wenchao.kiosk.R.id.lock_button);
        Button unlock_btn = (Button)findViewById(wenchao.kiosk.R.id.unlock_button);
        Button appButton = (Button) findViewById(R.id.appButton);
        lock_btn.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                startLockTask();
                return false;
            }
        });
        unlock_btn.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                stopLockTask();
                return false;
            }
        });
        appButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                final Intent intentDeviceTest = new Intent("android.intent.action.MAIN");
                intentDeviceTest.setComponent(new ComponentName("com.example.hello1","com.example.hello1.MainActivity"));
                startActivity(intentDeviceTest);
            }
        });
    }

