Turns out, however, that is a specialty case that we are unlikely to use very often.
You don't need to develop your own provider if you don't intend to share your data with other applications.So, will pass on them for now.
You don't need to develop your own provider if you don't intend to share your data with other applications.So, will pass on them for now.
When your app is installed on a device, the system identifies your intent filters and adds the information to an internal catalog of intents supported by all installed apps.
{
"project_info": {
"project_id": "fromandbackagain",
"project_number": "1009647335975",
"name":"FromAndBackAgain"},
"client":[
{
"client_info": {
"client_id": "android:com.larkintuckerllc.helloandroid",
"client_type":1,
"android_client_info": {
"package_name":"com.larkintuckerllc.helloandroid"
}
},
"oauth_client":[],
"services": {
"analytics_service":{
"status":1
},
"cloud_messaging_service": {
"status":2,"apns_config":[]
},
"appinvite_service":
{
"status":1,"other_platform_oauth_client":[]
},
"google_signin_service":{
"status":1
},
"ads_service":{
"status":1
}
}
}
],
"ARTIFACT_VERSION":"1"
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.larkintuckerllc.helloandroid" >
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="false"
/>
</manifest>
supports-screens: 'small' 'normal' 'large'This only targets the APK to the proper devices, now to actually force an orientation for the activities:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.larkintuckerllc.helloandroid" >
<uses-feature android:name="android.hardware.screen.portrait" />
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="false"
/>
<application>
<activity
android:name=".MainActivity"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".ThingActivity"
android:screenOrientation="portrait">
</activity>
</application>
</manifest
uses-feature: name='android.hardware.screen.portrait'With all this in place, here are the changes to the code to support this configuration: https://github.com/larkintuckerllc/HelloAndroid/commit/09e643979d3e15980382fa31b22dbfdc3cb67cfc
uses-feature: name='android.hardware.bluetooth'Ok, for our application we startup with a minimal set of feature requirements:
uses-implied-feature: name='android.hardware.bluetooth' reason='requested android.permission.BLUETOOTH permission, requested android.permission.BLUETOOTH_ADMIN permission, and targetSdkVersion > 4'
uses-feature: name='android.hardware.location'
uses-implied-feature: name='android.hardware.location' reason='requested android.permission.ACCESS_COARSE_LOCATION permission, and requested android.permission.ACCESS_FINE_LOCATION permission'
uses-feature: name='android.hardware.location.gps'
uses-implied-feature: name='android.hardware.location.gps' reason='requested android.permission.ACCESS_FINE_LOCATION permission'
uses-feature: name='android.hardware.location.network'
uses-implied-feature: name='android.hardware.location.network' reason='requested android.permission.ACCESS_COARSE_LOCATION permission'
uses-feature: name='android.hardware.screen.portrait'
uses-implied-feature: name='android.hardware.screen.portrait' reason='one or more activities have specified a portrait orientation'
uses-feature: name='android.hardware.telephony'
uses-implied-feature: name='android.hardware.telephony' reason='requested a telephony permission'
uses-feature: name='android.hardware.touchscreen'
uses-implied-feature: name='android.hardware.touchscreen' reason='default feature for all apps'
uses-feature: name='android.hardware.wifi'
uses-implied-feature: name='android.hardware.wifi' reason='requested android.permission.ACCESS_WIFI_STATE permission, and requested android.permission.CHANGE_WIFI_STATE permission'
uses-feature: name='android.hardware.touchscreen'uses-implied-feature: name='android.hardware.touchscreen' reason='default feature for all apps'We first try to have the app make a phone call (say on a menu click) with the following:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_hello) {
Snackbar
.make(findViewById(R.id.snackbarPosition), R.string.snackbar_text, Snackbar.LENGTH_LONG)
.show();
return true;
}
if (id == R.id.action_call) {
Intent phoneCallIntent = new Intent(Intent.ACTION_CALL);
phoneCallIntent.setData(Uri.parse("tel:3524748328"));
startActivity(phoneCallIntent);
}
return super.onOptionsItemSelected(item);
}
<uses-permission android:name="android.permission.CALL_PHONE" />
uses-feature: name='android.hardware.telephony'uses-implied-feature: name='android.hardware.telephony' reason='requested a telephony permission'uses-feature: name='android.hardware.touchscreen'uses-implied-feature: name='android.hardware.touchscreen' reason='default feature for all apps'
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_hello:
Snackbar
.make(findViewById(R.id.snackbarPosition), R.string.snackbar_text, Snackbar.LENGTH_LONG)
.show();
return true;
case R.id.action_call:
if (((TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE)).getLine1Number()
== null) {
Snackbar
.make(findViewById(R.id.snackbarPosition), R.string.no_telephony, Snackbar.LENGTH_LONG)
.show();
return true;
}
Intent phoneCallIntent = new Intent(Intent.ACTION_CALL);
phoneCallIntent.setData(Uri.parse("tel:3524748328"));
startActivity(phoneCallIntent);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
<uses-feature android:name="android.hardware.telephony" android:required="false" /> <uses-permission android:name="android.permission.CALL_PHONE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" />
uses-feature-not-required: name='android.hardware.telephony'The problem, however, now is that the app still has the call menu item and dynamically changing the menu in code adds a bit more complexity (especially if one has to do it repeatedly). This is where we use multiple APK support.
uses-feature: name='android.hardware.touchscreen'
uses-implied-feature: name='android.hardware.touchscreen' reason='default feature for all apps'
uses-feature: name='android.hardware.telephony'uses-feature: name='android.hardware.touchscreen'uses-implied-feature: name='android.hardware.touchscreen' reason='default feature for all apps'notelephony
uses-feature: name='android.hardware.touchscreen'uses-implied-feature: name='android.hardware.touchscreen' reason='default feature for all apps'
public void onClick(View view) {
Intent intent = new Intent(MainActivity.this,ThingActivity.class);
intent.putExtra("id", name.getText());
startActivity(intent);
}
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_thing);
String id = getIntent().getStringExtra("id");
((TextView)findViewById(R.id.name)).setText(id);
}