編輯:關於Android編程
如有5個頻道需要內置,即燒完軟件後第一次進入FM,還沒有進行搜索時,列表就可以始終顯示內置頻道
FMRadioService.java 1.private int defaultChannels[] = new int[] {875, 903, 918, 942, 1025};//自定義內置頻道 2.initService()中添加insertDefaultStation(defaultChannels); 3.定義insertDefaultStation()函數 private int[] insertDefaultStation(int[] channels) { LogUtils.d(TAG, insertDefaultStation.firstValidChannel: + Arrays.toString(channels)); int firstValidChannel = mCurrentStation; int channelNum = 0; if (null != channels) { Arrays.sort(channels); int size = channels.length; // Save searched stations into database by batch ArrayListops = new ArrayList (); String defaultStationName = getString(R.string.default_station_name); for (int i = 0; i < size; i++) { if (FMRadioUtils.isValidStation(channels[i])) { if (0 == channelNum) { firstValidChannel = channels[i]; } if (!FMRadioStation.isDefaultStation(mContext, channels[i])) { ops.add(ContentProviderOperation.newInsert(Station.CONTENT_URI) .withValue(Station.COLUMN_STATION_NAME, defaultStationName) .withValue(Station.COLUMN_STATION_FREQ, channels[i]) .withValue(Station.COLUMN_STATION_TYPE, FMRadioStation.STATION_TYPE_SEARCHED) .build()); } channelNum++; } } // Save search stations to database by batch try { mContext.getContentResolver().applyBatch(FMRadioStation.AUTHORITY, ops); } catch (RemoteException e) { LogUtils.d(TAG, Exception when applyBatch searched stations + e); } catch (OperationApplicationException e) { LogUtils.d(TAG, Exception when applyBatch searched stations + e); } } LogUtils.d(TAG, insertDefaultStation.firstValidChannel: + firstValidChannel + ,channelNum: + channelNum); return (new int[] { firstValidChannel, channelNum }); } 4.handleMessage()->case FMRadioListener.MSGID_SCAN_FINISHED:中 result = insertSearchedStation(channels); insertDefaultStation(defaultChannels);//添加此行 5.FMRadioStation.java中添加 public static boolean isDefaultStation(Context context, int iStation) { return isStationExist(context, iStation, STATION_TYPE_SEARCHED); }
注冊很多app或者網絡賬戶的時候,經常需要手機獲取驗證碼,來完成注冊,那時年少,只是覺得手機獲取驗證碼這件事兒很好玩,並沒有關心太多,她是如何實現的,以及她背後的故事到底
Android mvp 架構的自述中我簡單的介紹了mvp,以及怎麼寫mvp。我自己也將mvp運用到了項目中,其實mvp並沒有固定的寫法,正確的去理解架構的思想,都可以有自
配置Ubantu系統服務器,需要在“終端”輸入指定的命令來安裝指定的程序,進行對應的操作,類似於Windows中的命令行,因此在進行接下來的配置操
使用SlidingTabLayout需要准備2個類,分別是 SlidingTabLayout,與SlidingTabStrip,,放進項目中時只用修改下包名即可。效果制作