8

我在 Play Store 上发布了我的应用程序,但它不适用于平板电脑。我在 Google Play 商店中检查了应用程序的功能,经过一些研究发现我的应用程序具有一些电话功能,我认为这是有罪的一方。这是我的清单文件。

<uses-sdk
        android:minSdkVersion="7"
        android:targetSdkVersion="17" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission>
    <uses-permission android:name="android.permission.SEND_SMS" />

    <!-- GCM requires a Google account. -->
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />

    <!-- Keeps the processor from sleeping when a message is received. -->
    <uses-permission android:name="android.permission.WAKE_LOCK" />

    <permission
        android:name=".permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

    <uses-permission android:name=".permission.C2D_MESSAGE" />

    <!-- This app has permission to register and receive data message. -->
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <!-- Keeps the device on vibrating mode when a message is received. -->
    <uses-permission android:name="android.permission.VIBRATE" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Black.NoTitleBar" >

        <receiver
            android:name="com.google.android.gcm.GCMBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <category android:name="" />
            </intent-filter>
        </receiver>

        <service android:name=".GCMIntentService" />

        <activity
            android:name=".Splash"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name=".MainActivity"
            android:screenOrientation="portrait">
        </activity>

           <activity
            android:name=".SelectedArticlePush"
            android:screenOrientation="portrait">
        </activity>

        <activity
            android:name=".ActusScreen"
            android:screenOrientation="portrait">
        </activity>

          <activity
            android:name=".MentionLegale"
            android:screenOrientation="portrait">
        </activity>

        <activity
            android:name=".SelectedArticle"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateAlwaysHidden|adjustPan">>
        </activity>

        <activity
            android:name=".ReglementScreen"
            android:screenOrientation="portrait">
        </activity>

        <activity
            android:name=".SelectedReglementation"
            android:screenOrientation="portrait">
        </activity>

        <activity
            android:name=".FavoriteScreen"
            android:screenOrientation="portrait">
        </activity>

        <activity
            android:name=".AlertScreen"
            android:screenOrientation="portrait">
        </activity>

        <activity
            android:name=".ClubScreen"
            android:screenOrientation="portrait">
        </activity>

         <activity
            android:name="ClubMi"
            android:screenOrientation="portrait">
        </activity>

        <activity
            android:name=".DisplayWeb"
            android:screenOrientation="portrait">
        </activity>

         <activity
            android:name=".Contact"
            android:screenOrientation="portrait">
        </activity>

         <activity
            android:name=".tab.TabClubMi"
            android:screenOrientation="portrait">
        </activity>

        <activity
            android:name=".SMS"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.Transparent" >
        </activity>

    </application>

     <supports-screens 
          android:largeScreens="true" 
          android:normalScreens="true" 
          android:smallScreens="true" 
          android:resizeable="true" 
          android:anyDensity="true" />

我相信<uses-permission android:name="android.permission.SEND_SMS" />会激活电话功能。但是我需要这个权限才能发送短信。如果在平板电脑中运行,任何人都可以告诉我是否有另一种方法可以绕过它。

4

2 回答 2

15

将 uses-feature 块添加到您的清单中:

<uses-feature
    android:name="android.hardware.telephony"
    android:required="false" >
</uses-feature>

以上告诉设备您的应用程序中使用了此功能。android:required="false"但是,确保这不是严格的要求,并且无论支持该功能的设备如何,都将安装应用程序android.hardware.telephony

然而,这产生了一个新问题。不用担心。解决方案如下。:-)

当不支持该android.hardware.telephony功能的设备尝试以任何方式使用该功能时会发生什么?在您的情况下,发送短信。一个简单的解决方案是检查设备是否具有使用电话功能的能力。

TelephonyManager tm = (TelephonyManager) getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
if (tm.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE)  {
    // SHOW A DIALOG, A TOAST OR A NOTIFICATION TO TELL THE USER THAT THE FEATURE IS MISSING
} else {
    // RUN THE CODE TO SEND OUT THE SMS
}

我认为这是一种解决方法,以防运行它的设备是 CDMA 设备。

String strTM = ((TelephonyManager) getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE)).getLine1Number();
if (strTM == null)  {
    // SHOW A DIALOG, A TOAST OR A NOTIFICATION TO TELL THE USER THAT THE FEATURE IS MISSING
} else {
    // RUN THE CODE TO SEND OUT THE SMS
}

上面的任何一个代码块都需要READ_PHONE_STATE权限:

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

PackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)如果设备具有上述功能,还有另一种检查(使用)的方法。我个人从来没有测试过它,但 OP 表明它有效。https://stackoverflow.com/a/6568243/450534

于 2013-04-16T11:38:43.787 回答
2

您忘记xlargeScreensManifest.

<supports-screens
    android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:xlargeScreens="true" />

编辑:<uses-permissions>标签不会在设备上强制执行任何硬件或功能,只是标签<uses-feature>强制执行功能,当required设置为true.

于 2013-04-16T11:05:56.127 回答