0

Hello all i am integrating ola money with in my android app now the problem i am facing is that in their docs it is given that first check for whether the app is installed and for that they have given below code to see that, now i am having ola cabs app installed in my android device but this function is returning false i dont know what i am doing wrong, if somebody has integrated ola in android please tellme how is it working for you

private boolean check_olacabs() {
   try {
        context.getPackageManager().getApplicationInfo("com.test.olacabs", 0); 
        return true;
   } catch (Exception e) {
        return false;
   }
}

Thank you in advance

aman verma
  • 732
  • 1
  • 8
  • 26

1 Answers1

1

Replace your code with this.

private boolean check_olacabs() {

   PackageManager pm = getPackageManager();

     try {
         pm.getPackageInfo("com.olacabs.customer", PackageManager.GET_ACTIVITIES);
         return true;
     } catch (PackageManager.NameNotFoundException e) {
         return false;
     }

}
Nikunj
  • 3,937
  • 19
  • 33
  • thanks a lot man for your help it worked also can you please tell me inside startActivityForResult(intent); with intent i have to send one integer value also what have send example startActivityForResult(intent, number); – aman verma Nov 28 '15 at 05:33
  • i mean with startActivityForResult we must send an integer with intent what is the number you send with the intent ?? – aman verma Nov 28 '15 at 07:43
  • we have to sent requestCode with startActivityForResult(intent, requestCode) just to verify at the time of onActivityResult(). check http://stackoverflow.com/questions/10407159/how-to-manage-startactivityforresult-on-android – Nikunj Nov 28 '15 at 09:23
  • also in my case what is happening is that when i am passing my intent to olacabs app then no balance page is showing i mean do i have to design that or what ?? – aman verma Nov 28 '15 at 10:08
  • code of my intent try { Intent intent = new Intent("com.olacabs.olamoney.pay"); intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); intent.putExtra("bill", bill); //Pass the string representation of the json bill intent.setPackage("com.test.olacabs"); startActivityForResult(intent, 100); } catch(ActivityNotFoundException e) { /*Activity not found exception - route the flow through webview*/ } – aman verma Nov 28 '15 at 10:09