AndroidSDK 업그레이드 시 발생할 수 있는 문제

5374 단어
수필.
  • android6.0(api23)SDK 이후 Notification에서 setLatest EventInfo가 폐기됨;새로운 해결 방법은 새로운 Builder 대상을 만들고 이전의 notification을.setLatestEventInfo(this,"this is content title","this is content text",Intent);builder로 바꿉니다.setContentTitle(titile); builder.setContentText(content); builder.setContentIntent(contentItent); 다음과 같습니다:
  • public static void showNotice(Context context, String titile,
            String content, Intent intent, int ioc, int userSound) {
            Notification.Builder builder = new Notification.Builder(context);// Notification.Builder 
            UserMsgSharedPreference uspf = new UserMsgSharedPreference(context);
            int requestId = uspf.getRequestId();
            PendingIntent contentItent = PendingIntent.getActivity(context,
                    requestId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
            builder.setContentTitle(titile);
            builder.setContentText(content);
            builder.setContentIntent(contentItent);// intent
            requestId++;
            uspf.setRequestId(requestId);
    
            mNotificationManager = (NotificationManager) context
                    .getSystemService(Context.NOTIFICATION_SERVICE);
    
            int notifyId = uspf.getNotifyId();
            Notification notification = builder.build();// builder notification
            if (userSound == Notification.DEFAULT_SOUND) {
                notification.defaults = Notification.DEFAULT_SOUND; //  , / 
            } else {
                notification.sound = Uri.parse("android.resource://" + context.getPackageName() + "/" + userSound);
            }
            notification.defaults |= Notification.DEFAULT_VIBRATE;// -- 
    
            notification.flags = Notification.FLAG_AUTO_CANCEL;// -- 
            notification.icon = ioc;
            notification.when = System.currentTimeMillis();
            mNotificationManager.notify(notifyId, notification);
            notifyId++;
            uspf.setNotifyId(notifyId);
        }
    
  • android 6.0(api 23)SDK, org를 제공하지 않습니다.apache.http.*(몇 가지 클래스만 유지) Android Studion 솔루션
  • android {
        useLibrary 'org.apache.http.legacy'
    }
    
  • Android6.0 이후에는 동적 신청 권한이 필요합니다. 다음은 Google에서 제공하는 데모 Google 데모 주소 아래에 별도로 신청해야 하는 권한입니다. 모두 9개 그룹으로 나뉘어 있으며, 그룹마다 하나의 권한이 있으면 전체 권한을 사용할 수 있습니다.
  • group:android.permission-group.CONTACTS
    permission:android.permission.WRITE_CONTACTS
    permission:android.permission.GET_ACCOUNTS
    permission:android.permission.READ_CONTACTS
    
    group:android.permission-group.PHONE
    permission:android.permission.READ_CALL_LOG
    permission:android.permission.READ_PHONE_STATE
    permission:android.permission.CALL_PHONE
    permission:android.permission.WRITE_CALL_LOG
    permission:android.permission.USE_SIP
    permission:android.permission.PROCESS_OUTGOING_CALLS
    permission:com.android.voicemail.permission.ADD_VOICEMAIL
    
    group:android.permission-group.CALENDAR
    permission:android.permission.READ_CALENDAR
    permission:android.permission.WRITE_CALENDAR
    
    group:android.permission-group.CAMERA
    permission:android.permission.CAMERA
    
    group:android.permission-group.SENSORS
    permission:android.permission.BODY_SENSORS
    
    group:android.permission-group.LOCATION
    permission:android.permission.ACCESS_FINE_LOCATION
    permission:android.permission.ACCESS_COARSE_LOCATION
    
    group:android.permission-group.STORAGE
    permission:android.permission.READ_EXTERNAL_STORAGE
    permission:android.permission.WRITE_EXTERNAL_STORAGE
    
    group:android.permission-group.MICROPHONE
    permission:android.permission.RECORD_AUDIO
    
    group:android.permission-group.SMS
    permission:android.permission.READ_SMS
    permission:android.permission.RECEIVE_WAP_PUSH
    permission:android.permission.RECEIVE_MMS
    permission:android.permission.RECEIVE_SMS
    permission:android.permission.SEND_SMS
    permission:android.permission.READ_CELL_BROADCASTS
    

    다음은 AndroidManifest에서만 사용할 수 있는 일반 권한입니다.xml에서 신청하시면 됩니다.
    android.permission.ACCESS_LOCATION_EXTRA_COMMANDS
      android.permission.ACCESS_NETWORK_STATE
      android.permission.ACCESS_NOTIFICATION_POLICY
      android.permission.ACCESS_WIFI_STATE
      android.permission.ACCESS_WIMAX_STATE
      android.permission.BLUETOOTH
      android.permission.BLUETOOTH_ADMIN
      android.permission.BROADCAST_STICKY
      android.permission.CHANGE_NETWORK_STATE
      android.permission.CHANGE_WIFI_MULTICAST_STATE
      android.permission.CHANGE_WIFI_STATE
      android.permission.CHANGE_WIMAX_STATE
      android.permission.DISABLE_KEYGUARD
      android.permission.EXPAND_STATUS_BAR
      android.permission.FLASHLIGHT
      android.permission.GET_ACCOUNTS
      android.permission.GET_PACKAGE_SIZE
      android.permission.INTERNET
      android.permission.KILL_BACKGROUND_PROCESSES
      android.permission.MODIFY_AUDIO_SETTINGS
      android.permission.NFC
      android.permission.READ_SYNC_SETTINGS
      android.permission.READ_SYNC_STATS
      android.permission.RECEIVE_BOOT_COMPLETED
      android.permission.REORDER_TASKS
      android.permission.REQUEST_INSTALL_PACKAGES
      android.permission.SET_TIME_ZONE
      android.permission.SET_WALLPAPER
      android.permission.SET_WALLPAPER_HINTS
      android.permission.SUBSCRIBED_FEEDS_READ
      android.permission.TRANSMIT_IR
      android.permission.USE_FINGERPRINT
      android.permission.VIBRATE
      android.permission.WAKE_LOCK
      android.permission.WRITE_SYNC_SETTINGS
      com.android.alarm.permission.SET_ALARM
      com.android.launcher.permission.INSTALL_SHORTCUT
      com.android.launcher.permission.UNINSTALL_SHORTCUT
    

    좋은 웹페이지 즐겨찾기