如何使应用程序在所有版本的Android中工作?

时间:2013-10-28 05:36:26

标签: android

大家好,我开发了一个类似真正的caller.in的应用程序,我只是在显示     在toast中的联系号码,tats it.i在android 2.2版(api 8)中编译了这个。     应用程序在Android 2.3和2.3.3中工作正常,但不是在4.0.1和4.1.0 ......也许是     问题.. ????

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


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


<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

     <receiver android:name=".CustomBroadcastReceiver">
    <intent-filter>
            <action android:name="android.intent.action.PHONE_STATE" />     
    </intent-filter>
    </receiver>



</application>


this is my logcat error on android emulator api 17

10-28 07:22:28.950: D/CallNotifier(392): RINGING... (new)
10-28 07:22:28.950: D/CallNotifier(392): onNewRingingConnection(): state = RINGING, conn = {  incoming: true state: INCOMING post dial state: NOT_STARTED }
10-28 07:22:28.998: D/CallNotifier(392): SignalInfoTonePlayer.run(toneId = 98)...
10-28 07:22:29.078: D/PhoneNumberUtils(392): System property doesn't provide any emergency numbers. Use embedded logic for determining ones.
10-28 07:22:29.148: D/PhoneStatusBar(664): disable: < expand icons ALERTS* ticker system_info back home recent clock search >
10-28 07:22:29.258: D/AccelerometerListener(392): enable(false)
10-28 07:22:29.328: I/Choreographer(392): Skipped 45 frames!  The application may be doing too much work on its main thread.

10-28 07:22:29.648: W/CallNotifier(392): CallerInfo query took too long; look up local fallback cache.
10-28 07:22:29.657: D/CallNotifier(392): Failed to find fallback cache. Use default ringer tone.
10-28 07:22:29.657: W/CallNotifier(392): CallerInfo query took too long; falling back to default ringtone
10-28 07:22:29.808: D/CallNotifier(392): showIncomingCall()...  phone state = RINGING
10-28 07:22:29.867: W/Trace(289): Unexpected value from nativeGetEnabledTags: 0
10-28 07:22:29.867: W/Trace(289): Unexpected value from nativeGetEnabledTags: 0
10-28 07:22:29.908: W/Trace(405): Unexpected value from nativeGetEnabledTags: 0
10-28 07:22:29.918: W/Trace(405): Unexpected value from nativeGetEnabledTags: 0
10-28 07:22:29.968: W/Trace(664): Unexpected value from nativeGetEnabledTags: 0
10-28 07:22:30.069: W/Trace(664): Unexpected value from nativeGetEnabledTags: 0
10-28 07:22:30.219: I/Choreographer(664): Skipped 140 frames!  The application may be doing too much work on its main thread.
10-28 07:22:30.249: W/Trace(664): Unexpected value from nativeGetEnabledTags: 0
10-28 07:22:30.249: W/Trace(664): Unexpected value from nativeGetEnabledTags: 0
10-28 07:22:30.308: D/MediaPlayer(392): Couldn't open file on client side, trying server side
10-28 07:22:30.308: W/Trace(664): Unexpected value from nativeGetEnabledTags: 0
10-28 07:22:30.318: W/Trace(664): Unexpected value from nativeGetEnabledTags: 0
10-28 07:22:30.369: W/Trace(664): Unexpected value from nativeGetEnabledTags: 0
10-28 07:22:30.398: W/Trace(664): Unexpected value from nativeGetEnabledTags: 0
10-28 07:22:30.448: W/Trace(664): Unexpected value from nativeGetEnabledTags: 0
10-28 07:22:30.448: W/Trace(664): Unexpected value from nativeGetEnabledTags: 0
10-28 07:22:30.578: E/MediaPlayerService(40): Couldn't open fd for content://settings/system/ringtone
10-28 07:22:30.578: E/MediaPlayer(392): Unable to to create media player
10-28 07:22:30.609: D/Ringtone(392): Problem opening; delegating to remote player
10-28 07:22:30.739: I/AudioService(289):  AudioFocus  requestAudioFocus() from AudioFocus_For_Phone_Ring_And_Calls
10-28 07:22:30.788: D/AudioHardwareInterface(40): setMode(RINGTONE)
10-28 07:22:31.058: D/MediaPlayer(664): Couldn't open file on client side, trying server side
10-28 07:22:31.078: E/MediaPlayerService(40): Couldn't open fd for content://settings/system/ringtone
10-28 07:22:31.199: E/MediaPlayer(664): Unable to to create media player
10-28 07:22:31.199: W/Ringtone(664): Remote playback not allowed: java.io.IOException: setDataSource failed.: status=0x80000000
10-28 07:22:31.258: D/Ringtone(664): Problem opening; delegating to remote player
10-28 07:22:31.279: W/Ringtone(664): Neither local nor remote playback available
10-28 07:22:31.568: W/Trace(392): Unexpected value from nativeGetEnabledTags: 0
10-28 07:22:31.619: W/Trace(392): Unexpected value from nativeGetEnabledTags: 0
10-28 07:22:31.968: I/ActivityManager(289): START u0 {act=android.intent.action.MAIN flg=0x10840000 cmp=com.android.phone/.InCallScreen} from pid -1
10-28 07:22:31.978: W/Trace(289): Unexpected value from nativeGetEnabledTags: 0
10-28 07:22:32.048: W/Trace(289): Unexpected value from nativeGetEnabledTags: 0
10-28 07:22:32.228: W/WindowManager(289): Failure taking screenshot for (164x246) to layer 21015
10-28 07:22:32.228: W/Trace(405): Unexpected value from nativeGetEnabledTags: 0
10-28 07:22:32.339: W/Trace(392): Unexpected value from nativeGetEnabledTags: 0
10-28 07:22:32.369: W/Trace(289): Unexpected value from nativeGetEnabledTags: 0
10-28 07:22:32.477: W/Trace(289): Unexpected value from nativeGetEnabledTags: 0
10-28 07:22:32.557: W/Trace(392): Unexpected value from nativeGetEnabledTags: 0
10-28 07:22:32.598: I/Choreographer(289): Skipped 31 frames!  The application may be doing too much work on its main thread.
10-28 07:22:32.618: W/Trace(392): Unexpected value from nativeGetEnabledTags: 0
10-28 07:22:32.677: D/InCallScreen(392): onNewIntent: intent = Intent { act=android.intent.action.MAIN flg=0x10c40000 cmp=com.android.phone/.InCallScreen }, phone state = RINGING

1 个答案:

答案 0 :(得分:0)

我认为你正在使用这样的

  TelephonyManager manager =(TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
  mPhoneNumber = manager.getLine1Number();

并敬酒 您使用的此方法是SDK中唯一可以执行此操作的方法,仅适用于SIM卡上存储号码的设备,(设置 - >关于电话 - >状态 - >检查号码是否可见,如果是,那么只显示数字)对于所有其他运营商,您将不得不要求用户手动输入电话号码