Skip to main content

Posts

Showing posts from August, 2019

How to Find specific App Installed in Mobile or Not

In Android sometimes we have to determine that the Specific app is installed in mobile or Not .So here is Code snippet to find the specific package name application installed or not . public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Add respective layout setContentView(R.layout.main_activity); // Use package name which we want to check boolean isAppInstalled = appInstalledOrNot("com.check.application"); // App package here if(isAppInstalled) { //This intent will help you to launch if the package is already installed Intent LaunchIntent = getPackageManager() .getLaunchIntentForPackage("com.check.application"); startActivity(LaunchIntent); Log.i("Application is already installed."); } else { // Do whatever we want to do if applicatio

how to parse XML Programmatically in Android

In Android some times we have to parse XML data to use in Application .So here the example for Parsing the XML data . Step 1: Create XMLParser.java Class and paste the code like :- import android.util.Log; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.util.EntityUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import java.io.IOException; import java.io.StringReader; import java.io.UnsupportedEncodingException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; public class XMLParser {