Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7693727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:09:21+00:00 2026-05-31T21:09:21+00:00

How to give alert if the app is already installed in android,if not how

  • 0

How to give alert if the app is already installed in android,if not how to provide the link to android market???
I tried here

Here in For loop i need to quit

  public void onClick(View v) 
    { 
          final PackageManager pm = getPackageManager();
           //here i get set of installed apps
         List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);

      for (ApplicationInfo packageInfo : packages) 
       {
            //how do i check for installed package with clicked package

          String data=packageInfo.packageName;

          if(data.equals("com.bb"))
          {
            String TAG ="MyActivity";
            Log.d(TAG, "Installed package :" + packageInfo.packageName);
            Log.d(TAG, "Launch Activity :" + pm.getLaunchIntentForPackage(packageInfo.packageName)); 
            Toast.makeText(Listing.this, "You have Installed this Package:com.bb" , Toast.LENGTH_SHORT).show();  

          }

                //if the package is not installed, do this

                  else 
          {


            String dictionary=items[position];
            Toast.makeText(Listing.this, dictionary , Toast.LENGTH_SHORT).show();


            if(dictionary.equalsIgnoreCase("Acronyms"))
            {
                String dictionary2="MAcronyms";
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse("https://play.google.com/store/apps/details?id=com." + dictionary2));
                startActivity(intent);
             }
                    }
              }   
             }

the problem is loop is still running if, if condition fails(for eg..55 times it enters else Block)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T21:09:23+00:00Added an answer on May 31, 2026 at 9:09 pm
         public void onClick(View v) 
          {
    
         String str = "aaa";
    
         if(package1(str)==1)
         {
             Toast.makeText(Listing.this, "You have Installed this Package:aaa" , Toast.LENGTH_SHORT).show();
         }
         else
         {
                String dictionary2="bba";
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse("https://play.google.com/store/apps/details?id=com." + dictionary2));
                startActivity(intent);
         }
    
      }
    
         }
    
    public int package1(String str)
    {
          int i=0;
    
          final PackageManager pm = getPackageManager();
            //get a list of installed apps.
          List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
    
          for (ApplicationInfo packageInfo : packages) 
           {
    
              String data=packageInfo.packageName;
              if(data.equals(str))
              {
                i=1;
    
               }
                    else
                        {
                       //i=0;
    
                         }
    
                     }
                     return i;
    
                  }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've use Parse to give my iOS and Android App notifications. But I want
I'm building a calander app for Android in appcelerator, but now I'm having some
I am using phonegap and sqlite to develop cross-platform mobile app for android,ios,blackberry.For reference
I am learning Perl/Tk. I want to give alert to the user whenever he/she
Is there any possibility to give a alert dialog at the time of open
I want to use the vibration alert for the accelerometer action in an app
how do i give a alert message in russian text? these chars means name
I'm wondering if it's possible to make an iphone app give the user an
I dont want my app to run in background, I only want to give
How can I give an alert View for multiple cells in a tableView, so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.