Tyre Pressure Readings in your App – Using Intent Filters

Have just updated Tyre Pressure Checker to allow other apps to use it’s capabilities. You can now have Tyre Pressure information for UK registered cars within your apps.

There are two methods for this you can either ‘hand off’ to Tyre Pressure Checker and that app will ask for a car registration then display the tyre pressure information for that car: (you will need TPC installed)

        Intent intent = new Intent(Intent.ACTION_SEARCH);
    	intent.setDataAndType(Uri.parse("DG10BBU"), "text/registration");
    	
    	try {
			startActivity(intent);
		} catch (ActivityNotFoundException e) {
			Toast.makeText(this, "Application not installed", Toast.LENGTH_LONG).show();
			intent = new Intent(Intent.ACTION_VIEW);
			intent.setData(Uri.parse("market://details?id=com.blundell.tyrechecker"));
			startActivity(intent);
		}

Or you can ‘request’ tyre pressure information and Tyre Pressure Checker will return you the information about that car for you to display as you please: (you will need TPC installed)

        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    	intent.setDataAndType(Uri.parse("DG10BBU"), "text/registration");
    	startActivityForResult(intent, 1234);

These are both examples of using Intent-Filters if you want more information see here:
https://developer.android.com/guide/topics/intents/intents-filters.html

I’ve written an example application so you can see it in action:

https://play.google.com/store/apps/details?id=com.blundell.tutorial.use

You can also view the source code here:

Example – Use Tyre Checker

Any questions, as usual just ask.