android铃声总结

2024-03-30 21:08
文章标签 android 总结 铃声

本文主要是介绍android铃声总结,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

感谢 大明同志辛苦制作。

        最近研究源码程序,改了改手机短信铃声的源码,总结了下铃声的代码,写个activity继承PreferenceActivity有:手机短信铃声,手机铃声,闹钟铃声,还有sdcard中的铃声,通过选择相应的铃声,然后读取到xml文件里面,通过读取preference.xml文件,intent传个参数进去intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, phoneUri);打开对话框的时候就默认选中上次被选中的音乐。程序流程:在onCreate()方法中加入addPreferencesFromResource(R.xml.preferences);加载xml文件。@Override重写onPreferenceTreeClick()方法,处理点击事件,在打开对话框铃声的时候,先读取xml文件,判断是否有值,如果有值,就传值intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, phoneUri);然后进行选择铃声。通过onActivityResult()接受传递过来的uri,系统默认的铃声是通过data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);方法来获取uri的,而sdcard中的铃声通过Uri pickedUri = data.getData();来获得选中的uri的,再然后通过editor.commit();  来提交接受过来的uri和音乐的名字整个流程大概就是这样。


 SoundSettingActivity.apk (49.5 KB, 下载次数: 14)  SoundSettingActivity.rar (198.83 KB, 下载次数: 288) 



33333.png  777777.png  666666.png 888888.png 


下面代码附上:

在SoundSettingActivity这个工程下面:

一、在com.cn.android.daming包的SoundSettingMainActivity.java类中的代码:
  1. <span style="font-size:16px;color:#000000;">package com.cn.android.daming;

  2. import android.content.Intent;
  3. import android.content.SharedPreferences;
  4. import android.media.Ringtone;
  5. import android.media.RingtoneManager;
  6. import android.net.Uri;
  7. import android.os.Bundle;
  8. import android.preference.Preference;
  9. import android.preference.PreferenceActivity;
  10. import android.preference.PreferenceManager;
  11. import android.preference.PreferenceScreen;

  12. public class SoundSettingMainActivity extends PreferenceActivity  {

  13.         private static final int SMS_RINGTONE_PICKED = 1;
  14.         private static final int PHONE_RINGTONE_PICKED = 2;
  15.         private static final int ALARM_RINGTONE_PICKED = 3;
  16.         private static final int SDCARD_RINGTONE_PICKED = 4;
  17.         
  18.         public static final String NOTIFICATION_RINGTONE    = "pref_notification_ringtone";
  19.         public static final String NOTIFICATION_RINGTONE_TITLE_NAME = "pref_notification_ringtone_name";
  20.         public static final String PHONE_RINGTONE    = "pref_phone_ringtone";
  21.         public static final String PHONE_RINGTONE_TITLE_NAME    = "pref_phone_ringtone_title_name";
  22.         public static final String ALARM_RINGTONE    = "pref_alarm_ringtone";
  23.         public static final String ALARM_RINGTONE_TITLE_NAME    = "pref_alarm_ringtone_title_name";
  24.         public static final String SDCARD_RINGTONE    = "pref_sdcard_ringtone";
  25.         public static final String SDCARD_RINGTONE_TITLE_NAME    = "pref_sdcard_ringtone_title_name";
  26.         
  27.         private String notificationStr;
  28.         private String phoneStr;
  29.         private String alarmStr;
  30.         private String sdcardStr;
  31.         
  32.         private Preference mMmsSoundsPref;
  33.         private Preference mPhoneSoundsPref;
  34.         private Preference mAlarmSoundsPref;
  35.         private Preference mSdcardSoundsPref;
  36.         
  37.         @Override
  38.     public void onCreate(Bundle savedInstanceState) {
  39.         super.onCreate(savedInstanceState);
  40.         addPreferencesFromResource(R.xml.preferences);
  41.         setMessagePreferences();
  42.         setDefaultPreferences();
  43.     }
  44.     
  45.     private void setMessagePreferences() {
  46.             mMmsSoundsPref = findPreference("pref_sms_ringtone");
  47.             mPhoneSoundsPref = findPreference("pref_phone_ringtone");
  48.             mAlarmSoundsPref = findPreference("pref_alarm_ringtone");
  49.             mSdcardSoundsPref = findPreference("pref_sdcard_ringtone");
  50.     }
  51.     
  52.     private void setDefaultPreferences(){
  53.             SharedPreferences innersharedPreferences = PreferenceManager.getDefaultSharedPreferences(SoundSettingMainActivity.this);
  54.             String notificationRingtoneTitleName = innersharedPreferences.getString(NOTIFICATION_RINGTONE_TITLE_NAME, null);
  55.             if(notificationRingtoneTitleName!=null){
  56.                     mMmsSoundsPref.setSummary(notificationRingtoneTitleName);
  57.             }else{
  58.                     mMmsSoundsPref.setSummary(getString(R.string.pref_summary_notification_ringtone));
  59.             }
  60.             
  61.             String phoneRingtoneTitleName = innersharedPreferences.getString(PHONE_RINGTONE_TITLE_NAME, null);
  62.             if(phoneRingtoneTitleName!=null){
  63.                     mPhoneSoundsPref.setSummary(phoneRingtoneTitleName);
  64.             }else{
  65.                     mPhoneSoundsPref.setSummary(getString(R.string.pref_summary_phone_ringtone));
  66.             }
  67.             
  68.             String alarmRingtoneTitleName = innersharedPreferences.getString(ALARM_RINGTONE_TITLE_NAME, null);
  69.             if(alarmRingtoneTitleName!=null){
  70.                     mAlarmSoundsPref.setSummary(alarmRingtoneTitleName);
  71.             }else{
  72.                     mAlarmSoundsPref.setSummary(getString(R.string.pref_summary_alarm_ringtone));
  73.             }
  74.             
  75.             String sdcardRingtoneTitleName = innersharedPreferences.getString(SDCARD_RINGTONE_TITLE_NAME, null);
  76.             if(sdcardRingtoneTitleName!=null){
  77.                     mSdcardSoundsPref.setSummary(sdcardRingtoneTitleName);
  78.             }else{
  79.                     mSdcardSoundsPref.setSummary(getString(R.string.pref_summary_sdcard_ringtone));
  80.             }
  81.     }

  82.         @Override
  83.         public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
  84.                         Preference preference) {
  85.                 if (preference == mMmsSoundsPref){
  86.                         doPickSmsRingtone();
  87.                 }
  88.                 else if(preference == mPhoneSoundsPref){
  89.                         doPickPhoneRingtone();
  90.                 }
  91.         else if(preference == mAlarmSoundsPref){
  92.                 doPickAlarmRingtone();
  93.                 }
  94.         else if(preference == mSdcardSoundsPref){
  95.                 doPickSdcardRingtone();
  96.         }
  97.                 return super.onPreferenceTreeClick(preferenceScreen, preference);
  98.         }
  99.         
  100.         private void doPickSmsRingtone(){
  101.                 SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);  
  102.                 notificationStr = sharedPreferences.getString(NOTIFICATION_RINGTONE, null); 
  103.             
  104.         Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
  105.         // Allow user to pick 'Default'
  106.         intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
  107.         // Show only ringtones
  108.         intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
  109.         //set the default Notification value
  110.         intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
  111.         // Don't show 'Silent'
  112.         intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);

  113.         Uri notificationUri;
  114.         if (notificationStr != null) {
  115.                 notificationUri = Uri.parse(notificationStr);
  116.             // Put checkmark next to the current ringtone for this contact
  117.             intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, notificationUri);
  118.         } else {
  119.             // Otherwise pick default ringtone Uri so that something is selected.
  120.                 notificationUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
  121.             // Put checkmark next to the current ringtone for this contact
  122.             intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, notificationUri);
  123.         }

  124.         // Launch!
  125.         startActivityForResult(intent, SMS_RINGTONE_PICKED);
  126.         }
  127.         
  128.         private void doPickPhoneRingtone(){
  129.                 SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);  
  130.                 phoneStr = sharedPreferences.getString(PHONE_RINGTONE, null); 
  131.                 
  132.                 Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
  133.         // Allow user to pick 'Default'
  134.         intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
  135.         // Show only ringtones
  136.         intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_RINGTONE);
  137.         //set the default Notification value
  138.         intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE));
  139.         // Don't show 'Silent'
  140.         intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
  141.         
  142.         Uri phoneUri;
  143.         if (phoneStr != null) {
  144.                 phoneUri = Uri.parse(phoneStr);
  145.             // Put checkmark next to the current ringtone for this contact
  146.             intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, phoneUri);
  147.         } else {
  148.             // Otherwise pick default ringtone Uri so that something is selected.
  149.                 phoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
  150.             // Put checkmark next to the current ringtone for this contact
  151.             intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, phoneUri);
  152.         }
  153.         
  154.         startActivityForResult(intent, PHONE_RINGTONE_PICKED);
  155.         }
  156.         
  157.         private void doPickAlarmRingtone(){
  158.                 SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);  
  159.                 alarmStr = sharedPreferences.getString(ALARM_RINGTONE, null); 
  160.                 
  161.                 Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
  162.         // Allow user to pick 'Default'
  163.         intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
  164.         // Show only ringtones
  165.         intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_ALARM);
  166.         //set the default Notification value
  167.         intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM));
  168.         // Don't show 'Silent'
  169.         intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
  170.         
  171.         Uri alarmUri;
  172.         if (alarmStr != null) {
  173.                 alarmUri = Uri.parse(alarmStr);
  174.             // Put checkmark next to the current ringtone for this contact
  175.             intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, alarmUri);
  176.         } else {
  177.             // Otherwise pick default ringtone Uri so that something is selected.
  178.                 alarmUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
  179.             // Put checkmark next to the current ringtone for this contact
  180.             intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, alarmUri);
  181.         }
  182.         
  183.         startActivityForResult(intent, ALARM_RINGTONE_PICKED);
  184.         }
  185.         
  186.         private void doPickSdcardRingtone(){
  187.                 SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);  
  188.                 sdcardStr = sharedPreferences.getString(SDCARD_RINGTONE, null); 
  189.                 
  190.                 Uri sdcardUri = null;
  191.             if (sdcardStr != null) {
  192.                     sdcardUri = Uri.parse(sdcardStr);
  193.             } 
  194.                 
  195.         Intent innerIntent = new Intent(Intent.ACTION_GET_CONTENT);
  196.         innerIntent.setType("audio/*");
  197.         //you could lookup the framework the type of audio,if you don`t want use the Recorder use the note code
  198. //        innerIntent.setType("audio/aac");
  199. //        innerIntent.setType("audio/mp3");
  200. //        innerIntent.setType("audio/midi");
  201.         // Put checkmark next to the current ringtone for this contact
  202.         innerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, sdcardUri);
  203.         Intent wrapperIntent = Intent.createChooser(innerIntent, null);
  204.         startActivityForResult(wrapperIntent, SDCARD_RINGTONE_PICKED);
  205.         }

  206.         @Override
  207.         protected void onResume() {
  208.                 setDefaultPreferences();
  209.                 super.onResume();
  210.         }

  211.         @Override
  212.         protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  213.                 SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);  
  214.         SharedPreferences.Editor editor = sharedPreferences.edit();  
  215.                 if (resultCode != RESULT_OK) {
  216.             return;
  217.         }
  218.                 
  219.                 switch (requestCode) {
  220.                       case SMS_RINGTONE_PICKED:{
  221.                               Uri pickedUri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
  222.                               if(null == pickedUri){
  223.                                       editor.putString(NOTIFICATION_RINGTONE_TITLE_NAME, getString(R.string.select_ringtone_slient));
  224.                                       editor.putString(NOTIFICATION_RINGTONE, null); 
  225.                                       editor.commit(); 
  226.                               }else{
  227.                                       Ringtone ringtone =  RingtoneManager.getRingtone(SoundSettingMainActivity.this, pickedUri);
  228.                                       String strRingtone = ringtone.getTitle(SoundSettingMainActivity.this);
  229.                                       editor.putString(NOTIFICATION_RINGTONE_TITLE_NAME, strRingtone);
  230.                                       editor.putString(NOTIFICATION_RINGTONE, pickedUri.toString());  
  231.                                       editor.commit();  
  232.                               }
  233.                               break;
  234.                       }
  235.                       case PHONE_RINGTONE_PICKED:{
  236.                               Uri pickedUri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
  237.                               if(null == pickedUri){
  238.                                       editor.putString(PHONE_RINGTONE_TITLE_NAME, getString(R.string.select_ringtone_slient));
  239.                                       editor.putString(PHONE_RINGTONE, null); 
  240.                                       editor.commit(); 
  241.                               }else{
  242.                                       phoneStr = pickedUri.toString();
  243.                                       Ringtone ringtone =  RingtoneManager.getRingtone(SoundSettingMainActivity.this, pickedUri);
  244.                                       String strRingtone = ringtone.getTitle(SoundSettingMainActivity.this);
  245.                                       editor.putString(PHONE_RINGTONE_TITLE_NAME, strRingtone);
  246.                                       editor.putString(PHONE_RINGTONE, pickedUri.toString());  
  247.                                       editor.commit();  
  248.                               }
  249.                               break;
  250.                       }
  251.                       case ALARM_RINGTONE_PICKED:{
  252.                               Uri pickedUri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
  253.                               if(null == pickedUri){
  254.                                       editor.putString(ALARM_RINGTONE_TITLE_NAME, getString(R.string.select_ringtone_slient));
  255.                                       editor.putString(ALARM_RINGTONE, null); 
  256.                                       editor.commit(); 
  257.                               }else{
  258.                                       Ringtone ringtone =  RingtoneManager.getRingtone(SoundSettingMainActivity.this, pickedUri);
  259.                                       String strRingtone = ringtone.getTitle(SoundSettingMainActivity.this);
  260.                                       editor.putString(ALARM_RINGTONE_TITLE_NAME, strRingtone);
  261.                                       editor.putString(ALARM_RINGTONE, pickedUri.toString());  
  262.                                       editor.commit();  
  263.                               }
  264.                               break;
  265.                       }
  266.                       case SDCARD_RINGTONE_PICKED:{
  267.                               Uri pickedUri = data.getData();
  268.                               if(null != pickedUri){
  269.                                       notificationStr = pickedUri.toString();
  270.                                       Ringtone ringtone =  RingtoneManager.getRingtone(SoundSettingMainActivity.this, pickedUri);
  271.                                       String strRingtone = ringtone.getTitle(SoundSettingMainActivity.this);
  272.                                       editor.putString(SDCARD_RINGTONE_TITLE_NAME, strRingtone);
  273.                                       editor.putString(SDCARD_RINGTONE, pickedUri.toString());  
  274.                                       editor.commit();  
  275.                               }
  276.                               break;
  277.                       }
  278.                       default:break;
  279.                 }
  280.         }
  281. }</span>
复制代码
二、在res目录下加入xml文件,加入preferences.xml中的代码:
  1. <span style="font-size:16px;"><?xml version="1.0" encoding="utf-8"?>
  2. <PreferenceScreen
  3.   xmlns:android="http://schemas.android.com/apk/res/android">
  4.           <PreferenceCategory android:title="@string/pref_sounds_storage_title"
  5.                               android:key="pref_key_storage_settings">
  6.                    <Preference         
  7.                             android:layout="?android:attr/preferenceLayoutChild"
  8.                         android:key="pref_sms_ringtone"
  9.                         android:ringtoneType="notification"
  10.                         android:title="@string/pref_title_notification_ringtone"
  11.                         android:summary="@string/pref_summary_notification_ringtone"
  12.                />
  13.                <Preference         
  14.                             android:layout="?android:attr/preferenceLayoutChild"
  15.                         android:key="pref_phone_ringtone"
  16.                         android:ringtoneType="notification"
  17.                         android:title="@string/pref_title_phone_ringtone"
  18.                         android:summary="@string/pref_summary_phone_ringtone"
  19.                />
  20.                <Preference         
  21.                             android:layout="?android:attr/preferenceLayoutChild"
  22.                         android:key="pref_alarm_ringtone"
  23.                         android:ringtoneType="notification"
  24.                         android:title="@string/pref_title_alarm_ringtone"
  25.                         android:summary="@string/pref_summary_alarm_ringtone"
  26.                />
  27.                <Preference         
  28.                             android:layout="?android:attr/preferenceLayoutChild"
  29.                         android:key="pref_sdcard_ringtone"
  30.                         android:ringtoneType="notification"
  31.                         android:title="@string/pref_title_sdcard_ringtone"
  32.                         android:summary="@string/pref_summary_sdcard_ringtone"
  33.                />
  34.           </PreferenceCategory>
  35. </PreferenceScreen>
  36. </span>
复制代码
三、在values目录下的string中的代码:
  1. <span style="font-size:16px;"><?xml version="1.0" encoding="utf-8"?>
  2. <resources>
  3.     <string name="hello">Hello World, SoundSettingMainActivity!</string>
  4.     <string name="app_name">SoundSettingApp</string>
  5.     <string name="pref_sounds_storage_title">大明原创SoundSetting</string>
  6.     <string name="pref_title_notification_ringtone">选择短信铃声</string>
  7.     <string name="pref_summary_notification_ringtone">默认短信铃声</string>
  8.     <string name="pref_title_phone_ringtone">选择手机铃声</string>
  9.     <string name="pref_summary_phone_ringtone">默认手机铃声</string>
  10.     <string name="pref_title_alarm_ringtone">选择闹钟铃声</string>
  11.     <string name="pref_summary_alarm_ringtone">默认闹钟铃声</string>
  12.     <string name="pref_title_sdcard_ringtone">选择Sdcard中的铃声</string>
  13.     <string name="pref_summary_sdcard_ringtone">默认Sdcard铃声</string>
  14.     <string name="select_ringtone_slient">静音</string>
  15. </resources>
  16. </span>
复制代码
四、在AndroidManifest.xml中的代码:
  1. <span style="font-size:16px;"><?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3.       package="com.cn.android.daming"
  4.       android:versionCode="1"
  5.       android:versionName="1.0">
  6.     <uses-sdk android:minSdkVersion="8" />

  7.     <application android:icon="@drawable/icon" android:label="@string/app_name">
  8.         <activity android:name=".SoundSettingMainActivity"
  9.                   android:label="@string/app_name">
  10.             <intent-filter>
  11.                 <action android:name="android.intent.action.MAIN" />
  12.                 <category android:name="android.intent.category.LAUNCHER" />
  13.             </intent-filter>
  14.         </activity>
  15.     </application>
  16. </manifest></span>
复制代码
原文地址:http://www.eoeandroid.com/forum.php?mod=viewthread&tid=111007

这篇关于android铃声总结的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/862583

相关文章

Kubernetes常用命令大全近期总结

《Kubernetes常用命令大全近期总结》Kubernetes是用于大规模部署和管理这些容器的开源软件-在希腊语中,这个词还有“舵手”或“飞行员”的意思,使用Kubernetes(有时被称为“... 目录前言Kubernetes 的工作原理为什么要使用 Kubernetes?Kubernetes常用命令总

Python中实现进度条的多种方法总结

《Python中实现进度条的多种方法总结》在Python编程中,进度条是一个非常有用的功能,它能让用户直观地了解任务的进度,提升用户体验,本文将介绍几种在Python中实现进度条的常用方法,并通过代码... 目录一、简单的打印方式二、使用tqdm库三、使用alive-progress库四、使用progres

Android数据库Room的实际使用过程总结

《Android数据库Room的实际使用过程总结》这篇文章主要给大家介绍了关于Android数据库Room的实际使用过程,详细介绍了如何创建实体类、数据访问对象(DAO)和数据库抽象类,需要的朋友可以... 目录前言一、Room的基本使用1.项目配置2.创建实体类(Entity)3.创建数据访问对象(DAO

Java向kettle8.0传递参数的方式总结

《Java向kettle8.0传递参数的方式总结》介绍了如何在Kettle中传递参数到转换和作业中,包括设置全局properties、使用TransMeta和JobMeta的parameterValu... 目录1.传递参数到转换中2.传递参数到作业中总结1.传递参数到转换中1.1. 通过设置Trans的

C# Task Cancellation使用总结

《C#TaskCancellation使用总结》本文主要介绍了在使用CancellationTokenSource取消任务时的行为,以及如何使用Task的ContinueWith方法来处理任务的延... 目录C# Task Cancellation总结1、调用cancellationTokenSource.

Android WebView的加载超时处理方案

《AndroidWebView的加载超时处理方案》在Android开发中,WebView是一个常用的组件,用于在应用中嵌入网页,然而,当网络状况不佳或页面加载过慢时,用户可能会遇到加载超时的问题,本... 目录引言一、WebView加载超时的原因二、加载超时处理方案1. 使用Handler和Timer进行超

HarmonyOS学习(七)——UI(五)常用布局总结

自适应布局 1.1、线性布局(LinearLayout) 通过线性容器Row和Column实现线性布局。Column容器内的子组件按照垂直方向排列,Row组件中的子组件按照水平方向排列。 属性说明space通过space参数设置主轴上子组件的间距,达到各子组件在排列上的等间距效果alignItems设置子组件在交叉轴上的对齐方式,且在各类尺寸屏幕上表现一致,其中交叉轴为垂直时,取值为Vert

学习hash总结

2014/1/29/   最近刚开始学hash,名字很陌生,但是hash的思想却很熟悉,以前早就做过此类的题,但是不知道这就是hash思想而已,说白了hash就是一个映射,往往灵活利用数组的下标来实现算法,hash的作用:1、判重;2、统计次数;

Android实现任意版本设置默认的锁屏壁纸和桌面壁纸(两张壁纸可不一致)

客户有些需求需要设置默认壁纸和锁屏壁纸  在默认情况下 这两个壁纸是相同的  如果需要默认的锁屏壁纸和桌面壁纸不一样 需要额外修改 Android13实现 替换默认桌面壁纸: 将图片文件替换frameworks/base/core/res/res/drawable-nodpi/default_wallpaper.*  (注意不能是bmp格式) 替换默认锁屏壁纸: 将图片资源放入vendo

Android平台播放RTSP流的几种方案探究(VLC VS ExoPlayer VS SmartPlayer)

技术背景 好多开发者需要遴选Android平台RTSP直播播放器的时候,不知道如何选的好,本文针对常用的方案,做个大概的说明: 1. 使用VLC for Android VLC Media Player(VLC多媒体播放器),最初命名为VideoLAN客户端,是VideoLAN品牌产品,是VideoLAN计划的多媒体播放器。它支持众多音频与视频解码器及文件格式,并支持DVD影音光盘,VCD影