Time of Update: 2017-01-18
最近做區域網路socket串連問題,要在多個activity之間公用一個socket串連,就在網上搜了下資料,感覺還是application方法好用,帖出來分享下! Android中在不同Activity中傳遞變數,通常使用Intent中Bundle添加變數的操作方法。 儲存參數時: 複製代碼 代碼如下: Intent intent = new Intent(); intent.setClass(A.this, B.class); Bundle bundle = new Bundle();
Time of Update: 2017-01-18
primary_text_yellow.xml 複製代碼 代碼如下: <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2008 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
Time of Update: 2017-01-18
(效果如上圖所示)其實很簡單:比方說上面的容器是一個ListView複製代碼 代碼如下: <ListView android:id="@+id/listView_devices" android:layout_width="fill_parent" android:layout_height="fill_parent" <SPAN style="COLOR: #ff0000">
Time of Update: 2017-01-18
在軟體開發過程中,程式碼的複用,是非常重要的概念。我們總是需要使用一些現有的模組、包、架構,或開發自己的模組、包、架構,來實現對程式碼的複用。比如在JavaWeb編程過程中,經常使用的Struts和Spring等架構,就可以大大簡化我們的開發過程,提高開發效率。
Time of Update: 2017-01-18
我們開發一款軟體後,如果手機裝的軟體過多,去翻的話會很難翻的,所以,在首頁面有一個捷徑的話會很不錯的,下面是詳細代碼: 複製代碼 代碼如下: /** * 建立案頭捷徑 */ private void createShortcut() { SharedPreferences setting = getSharedPreferences("silent.preferences", 0); // 判斷是否第一次啟動應用程式(預設為true) boolean firstStart =
Time of Update: 2017-01-18
擷取網路資訊需要在AndroidManifest.xml檔案中加入相應的許可權。 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 1)判斷是否有網路連接 複製代碼 代碼如下: public boolean isNetworkConnected(Context context) { if (context != null) { ConnectivityManager
Time of Update: 2017-01-18
一、基本概念複製代碼 代碼如下: // 內容物件 private Context context; public FileService(Context context) { super(); this.context = context; } // 儲存檔案方法 public void save(String filename, String fileContent) throws Exception { FileOutputStream fos =
Time of Update: 2017-01-18
Android中實現定時器的四種方式第一種方式利用Timer和TimerTask1、繼承關係java.util.Timer基本方法schedule例如:timer.schedule(task, delay,period); //delay為long,period為long:從現在起過delay毫秒以後,每隔period毫秒執行一次。
Time of Update: 2017-01-18
首先來看一下使用Java語言編寫的Android應用程式從源碼到安裝包的整個過程,示意圖如下,其中包含編譯、連結和簽名等:(1)使用aapt工具產生R.java檔案可以先通過搭建好的Eclipse開發環境建立一個未編譯的Android工程,記的一定要將Eclipse中Project菜單下的Build Automatically選項前面的對勾去掉後再去建立工程。建立好未編譯的工程後,在命令列中輸入如下命令:d:\android-sdk-windows\platform-tools>aapt
Time of Update: 2017-01-18
如果是列表(單列多行形式)的使用ListView,如果是多行多列網狀形式的優先使用GridView。<?xml version="1.0" encoding="utf-8"?><GridView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" &
Time of Update: 2017-01-18
本文章總結了一段Android擷取通話時間程式碼,有需要的朋友可參考一下。我們知道安卓系統中通話時間長度應該是歸Callog管,所以建議去查查ContactProvider,或者是TelephonyProviderService測試可以的通話開始的時候啟動Service 記錄目前時間A, 然後stopSelf(); 另外在通話結束的時候再次啟動一下Service,再次獲得目前時間B, 然後把時間A和B進行比較處理String time =
Time of Update: 2017-01-18
今天看到EOE問答裡面有這“[Android 介面]NotificationManager 如何使用Bitmap做表徵圖”這樣一個問題,在論壇搜尋也沒有好的案例 特寫一個簡單的demo供大家參考 今天發布的是NotificationManager 使用Bitmap做表徵圖 關鍵code 複製代碼 代碼如下: public void notification(int flag) { Notification notification = new Notification();
Time of Update: 2017-01-18
Android 手機無法串連mac解決辦法一般的android串連mac 很方便不用安裝驅動就可以啦,可是不知道為什麼二般情況下有的android手機(小米2,華為等)就是串連不上,下來就說說二般情況下如何串連。1.關於本機-->更多資訊->概系統覽->系統報告->usb->你所串連的device-->供應商ID(Vendor ID)2.終端執行如下命令: echo 0x2717 >>
Time of Update: 2017-01-18
在匯入studio工程的時候,進行sync的時候,提示Error:Configuration with name 'default' not found.之前由於對gradle不熟悉,所以沒有找到原因,其實也是偷懶,沒有認真去排查問題,今天又遇到了,就折騰了會,把所有的設定檔都開啟看,最終解決問題了,發現盡然是個低級的不能低級的問題,故記錄下,警醒自己。1.開啟settings.gradle發現裡面有很多個include
Time of Update: 2017-01-18
本文執行個體為大家分享了Android連絡人字母排序的具體代碼,供大家參考,具體內容如下實現思路:首先說下布局,整個是一個相對布局,最下面是一個listview,listview上面是一個自訂的view(右邊顯示字母),最上面是一個textview(螢幕中間的方塊)。首先說一下右邊自訂view,字母是畫到view上面的,首先計算一下view的高度,然後除以存放字母數組的長的,得到每個字元的高度;每個字母的寬度都是一樣的,所以這裡直接設定30sp;listview顯示的是108個梁山好漢的名字;項
Time of Update: 2017-01-18
Android 調用系統相機拍攝擷取照片的兩種方法實現執行個體在我們Android開發中經常需要做這個一個功能,調用系統相機拍照,然後擷取拍攝的照片。下面是我總結的兩種方法擷取拍攝之後的照片,一種是通過Bundle來擷取壓縮過的照片,一種是通過SD卡擷取的原圖。下面是示範代碼:布局檔案:<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.
Time of Update: 2017-01-18
這篇文章是繼自訂EditText樣式之後的功能強化,對於實際應用項目有很大的參考意見,感興趣的朋友可以移步上一篇,”Android Studion自訂EditText樣式”.具體清除EditText常值內容功能代碼如下:package com.liheng;import android.content.Context;import android.graphics.Rect;import android.graphics.drawable.Drawable;import
Time of Update: 2017-01-18
自從Fragment出現,曾經有段時間,感覺大家談什麼都能跟Fragment談上關係,做什麼都要問下Fragment能實現不~~~哈哈,是不是有點過~~~本文力求為大家說明Fragment如何產生,什麼是Fragment,Fragment生命週期,如何靜態和動態使用Fragment,Fragment回退棧,Fragment事務;以及Fragment的一些特殊用途,例如:沒有布局的Fragment有何用處?Fragment如何與Activity互動?Fragment如何建立對話方塊?Fragmen
Time of Update: 2017-01-18
二、建立樣式日曆顯示的表格線,使用 Cell 填充圖形的邊框來實現,為了統一,我們先定義邊框線的顏色及線條精細。另外還要定義一系統填充樣式等。建立 color:color_calendar_border 表格線color_calendar_title_gregorian 標題列日期年月文字的顏色color_calendar_title_lunar
Time of Update: 2017-01-18
擷取網路資訊需要在AndroidManifest.xml檔案中加入相應的許可權。 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 1)判斷是否有網路連接 複製代碼 代碼如下:public boolean isNetworkConnected(Context context) { if (context != null) { ConnectivityManager