當前位置:首頁 » 安卓系統 » android經典代碼

android經典代碼

發布時間: 2022-06-24 13:49:08

Ⅰ android的代碼求解

getMenuInflater().inflate(R.menu.main, menu);
這也是添加菜單一種方式 通過樣式表添加 這樣你就能直接在menu.xml添加菜單了
if (id == R.id.action_settings)

進入if的條件是id值為R.id.action_settings

安卓手機有什麼好玩的代碼

具體如下:

1、*#*#7780#*#*,重設為原廠設定,不會刪除預設程序,及SD卡檔案。

2、*2767*3855#,重設為原廠設定,會刪除SD卡所有檔案。

3、*#*#273283*255*663282*#*#*,開啟一個能讓你備份媒體文件的地方,例如相片、聲音及影片等。

4、*#*#1472365#*#*,GPS 測試。

5、*#*#1575#*#*,其它 GPS 測試。

6、*#*#232331#*#*,藍牙測試。

7、*#*#0*#*#*,LCD 測試。

8,*#*#0842#*#*,裝置測試,例如振動、亮度。

9、*#*#2664#*#*,觸控屏幕測試。

10、*#*#3264#*#*,內存版本。

總結:

這些代碼不僅僅單純用於測試,如果能熟練利用代碼,在買新手機時我們可以進行測試,看看我們所購買的手機是不是 15 天機或者翻新機等。

Ⅲ 安卓手機整人代碼java大全

BEGBEGIN:IMELODY
VERSION:1.2
FORMAT:CLASS1.0
COMPOSER:MIK(23)Fomat
BEAT:180
MELODY:
("+<melody>+"@9999999999999999999999999)"

手機黑屏代碼

BEGIN:IMELODY
BEAT:1200
MELODY:(@600)
END:IMELODY

手機狂震代碼

BEGIN:IMELODY
VERSION:1.2
FORMAT:CLASS1.0
BEAT:100
MELODY:(@0)
END:IMELODY
說明
<1> 「@」後面的數字越大,重復次數越多

<2>把上面代碼復制,在計算機上保存為.txt文本文件,再改名為 .imy 文件

<3> imy 放到手機里的Audio文件夾

<4>寫簡訊(不是彩信) 寫簡訊時, 插入鈴聲對象(自定義鈴聲對象,就是剛才放在audio 里的imy 文件) 並發送, 對方只要是存在這個晶元漏洞,那麼則會產生上述所說效果.

Ⅳ 急需一個簡單的Android程序,需源代碼!

//最簡單的helloword
importandroid.app.Activity;
importandroid.os.Bundle;
importandroid.widget.TextView;

{
@Override
publicvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
TextViewtv=newTextView(this);
tv.setText("Hello,World!");
setContentView(tv);
}
}

Ⅳ android 代碼

public class ApkClientActivity extends Activity {
static final String TAG = "ApkClientActivity";
Context mContext;
DownloadManager manager ;
DownloadCompleteReceiver receiver;
Button downBtn ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mContext = this;
//獲取下載服務
manager =(DownloadManager)getSystemService(DOWNLOAD_SERVICE);
receiver = new DownloadCompleteReceiver();
downBtn = (Button)findViewById(R.id.downBtn);
downBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//創建下載請求
DownloadManager.Request down=new DownloadManager.Request (Uri.parse("http://192.168.0.66:8080/qqinput.apk"));
//設置允許使用的網路類型,這里是移動網路和wifi都可以
down.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE|DownloadManager.Request.NETWORK_WIFI);
//禁止發出通知,既後台下載
down.setShowRunningNotification(false);
//不顯示下載界面
down.setVisibleInDownloadsUi(false);
//設置下載後文件存放的位置
down.(mContext, null, "qqinput.apk");
//將下載請求放入隊列
manager.enqueue(down);
}
});
}
//接受下載完成後的intent
class DownloadCompleteReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if(intent.getAction().equals(DownloadManager.ACTION_DOWNLOAD_COMPLETE)){
long downId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);
Log.v(TAG," download complete! id : "+downId);
Toast.makeText(context, intent.getAction()+"id : "+downId, Toast.LENGTH_SHORT).show();
}
}
}

@Override
protected void onResume() {
registerReceiver(receiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
super.onResume();
}

@Override
protected void onDestroy() {
if(receiver != null)unregisterReceiver(receiver);
super.onDestroy();
}
}

其中在設置 down.setShowRunningNotification(false);時,需要添加相應的許可權:
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
否則,會報錯!

AndroidManifest.xml文件內容如下:

Xml代碼
<strong><uses-sdk android:minSdkVersion="9" /></strong>

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".ApkClientActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />

Ⅵ 怎麼用android編寫代碼

一、用RelativeLayout進行純代碼布局的理論基礎
1、RelativeLayout,顧名思義,就是以「相對」位置/對齊 為基礎的布局方式。
2、android.widget.RelativeLayout 有個繼承自android.view.ViewGroup.LayoutParams 的內嵌類 LayoutParams,使用這個類的實例
調用RelativeLayout.addView 就可以實現「相對布局」。 android.widget.RelativeLayout.LayoutParams 有一個構造函數:
RelativeLayout.LayoutParams(int w, int h),參數指定了子 View 的寬度和高度,這一點和其父類是一樣的。而實現相對布局的關
鍵在它的 兩個 addRule 方法上。anchor 參數指定可以是View 的 id(「相對於誰」)、RelativeLayout.TRUE(啟用某種對齊方式) 或者
是-1(應用於某些不需要 anchor 的 verb);AddRule 方法的 verb 參數指定相對的「動作」(以下常量均定義於
android.widget.RelativeLayout中,為了簡便不給出其全名):
3、ALIGN_BOTTOM、ALIGN_LEFT、 ALIGN_RIGHT、 ALIGN_TOP: 本 View 的 底邊/左邊/右邊/頂邊 和 anchor 指定的 View 的
底邊/左邊/右邊/頂邊 對齊。
ALIGN_WITH_PARENT_BOTTOM 、ALIGN_WITH_PARENT_LEFT 、 ALIGN_WITH_PARENT_RIGHT 、
ALIGN_WITH_PARENT_TOP : 和上面一組常量類似,只不過不需要再指定 anchor, 其 anchor 自動為 Parent View。
CENTER_HORIZONTAL、CENTER_IN_PARENT 、CENTER_VERTICAL : 如果 anchor 為 TRUE,在 Parent 中 水平居中/水平
和垂直均居中/垂直居中。
POSITION_ABOVE 、POSITION_BELOW 、 POSITION_TO_LEFT 、POSITION_TO_RIGHT : 本 View 位於 anchor 指定的 View
的上邊/下邊/左邊/右邊。
二、案例
1、布局文件如下

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF" >
<com..mapapi.map.MapView
android:id="@+id/_map_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true" >
</com..mapapi.map.MapView>
<RelativeLayout
android:id="@+id/anquan_map_l1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp" >
<ImageButton
android:id="@+id/but_of_lukuang"
android:layout_width="38.0dip"
android:layout_height="38.0dip"
android:background="@drawable/main_map_button_bg"
android:src="@drawable/maptraffic_icon_off" />
<ImageButton
android:id="@+id/btn_of_bobao"
android:layout_width="38.0dip"
android:layout_height="38.0dip"
android:layout_below="@id/but_of_lukuang"
android:layout_marginTop="5dp"
android:visibility="gone"
android:background="@drawable/main_map_button_bg"
android:src="@drawable/netfriend_bobao_n" />
<ImageButton
android:id="@+id/btn_of_layer"
android:layout_width="38.0dip"
android:layout_height="38.0dip"
android:layout_below="@+id/btn_of_bobao"
android:layout_marginTop="5dp"
android:background="@drawable/main_map_button_bg"
android:src="@drawable/main_map_icon_layer" />
</RelativeLayout>
</RelativeLayout>
2、代碼如下
//得到
mapButtonRL = (RelativeLayout) findViewById(R.id.anquan_map_l1);
RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
lp1.addRule(RelativeLayout.BELOW, R.id.btn_of_layer);
showModeButton = new Button(this);
showModeButton.setText("全部顯示");
showModeButton.setId(SHOW_MODE);
showModeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
mapButtonRL.addView(showModeButton, lp1);
RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
lp2.addRule(RelativeLayout.BELOW, SHOW_MODE);
positionButton = new Button(this);
positionButton.setText("位置");
positionButton.setId(POSITION);
positionButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
mapButtonRL.addView(positionButton, lp2);

Ⅶ 求黑馬程序員android4.0視頻源碼(已有視頻只給源代碼即可)和上課用的資料

現在學習Android的平台有很多的,B站或者是騰訊課堂都是可以的,我們在B站分享了很多經典的視頻教程,都是開源的,你可以去看看。

Ⅷ 安卓手機的快捷代碼例如*#06#

基本代碼
*#*#4636#*#*

顯示手機信息、電池信息、電池記錄、使用統計數據、WiFi
信息
*#*#7780#*#*
–重設為原廠設定,不會刪除預設程序,及
SD
卡檔案
*2767*3855#
–重設為原廠設定,會刪除
SD
卡所有檔案
*#*#34971539#*#*
–顯示相機相機韌體版本,或更新相機韌體
*#*#7594#*#*
–當長按關機按鈕時,會出現一個切換手機模式的窗口,包括:
靜音模式、飛航模式及關機,你可以用以上代碼,直接變成關機按鈕

Ⅸ 安卓手機開發者選項代碼大全

*#*#4636#*#*
顯示手機信息、電池信息、電池記錄、使用統計數據、WiFi 信息
*#*#7780#*#*
重設為原廠設定,不會刪除預設程序,及 SD 卡檔案。
*2767*3855#
重設為原廠設定,會刪除 SD 卡所有檔案。
*#*#34971539 #*#*
顯示相機相機韌體版本,或更新相機韌體
*#*#7594#*#*
當長按關機按鈕時,會出現一個切換手機模式的窗口,包括:
靜音模式、飛航模式及關機,你可以用以上代碼,直接變成關機按鈕。
*#*#273283*255*663282*#*#*
開啟一個能讓你備份媒體文件的地方,例如相片、聲音及影片等
*#*#197328640#*#*
啟動服務模式,可以測試手機部分設置及更改設定WLAN、GPS及藍牙測試的代碼
*#*#232339#*#*或*#*#526#*#*或*#*#528#*#*
WLAN 測試
*#*#232338#*#*
顯示WiFi MAC地址
*#*#1472365#*#*
GPS 測試
*#*#1575#*#*
其它GPS測試
*#*#232331#*#*
藍牙測試
*#*#232337#*#
顯示藍牙裝置地址
*#*#8255#*#*
啟動GTalk服務監視器顯示手機軟體版本的代碼
*#*#4986*2650468 #*#*
PDA、Phone、H/W、RFCallDate
*#*#1234#*#*
PDA及Phone
*#*#1111#*#*
FTA
SW 版本
*#*#2222#*#*
FTA HW 版本
*#*#44336#*#*
PDA、Phone、csc、build Time、an.name、changelist
number
各項硬體測試
*#*#0283#*#*
Packet
Loopback
*#*#0*#*#*
LCD 測試
*#*#0673#*#*或*#*#0289#*#*
Melody
測試
*#*#0842#*#*
裝置測試,例如振動、亮度
*#*#2663#*#*
觸控屏幕版本
*#*#2664#*#*
觸控屏幕測試
*#*#0588#*#*
接近感應器測試
*#*#3264#*#*
內存版本

Ⅹ android 代碼布局簡單的例子

LinearLayout linearLayout = new LinearLayout(context);
linearLayout.setOrientation(LinearLayout.VERTICAL);
linearLayout.setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
linearLayout.setGravity(Gravity.CENTER_HORIZONTAL);

ImageButton news = new ImageButton(context);
news.setId(85);
news.setOnClickListener(this);
news.setBackgroundResource(R.drawable.news);
news.setLayoutParams(new LayoutParams(33, 33));

linearLayout.addView(news);

這段代碼就動態把一個ImageButton添加到一個LinearLayout中去了~

同時設定了VIEW的長寬背景布局方式等~

同理,刪除掉使用的方法例如:

XXX.removeViewAt(index)

index就是這個子view在父view中是第(index+1)個添加進去的(index從0開始算的)

先嘗試去修改下,再有不懂的請留言~

幫你網路的 大致就這樣 下面有參考資料http://..com/question/255392766.html

熱點內容
資料庫的中文亂碼 發布:2024-05-09 04:41:00 瀏覽:750
永劫無間伺服器為什麼那麼爛 發布:2024-05-09 04:34:38 瀏覽:810
用哪個軟體配置華為企業路由器 發布:2024-05-09 04:23:58 瀏覽:521
簡易腳本 發布:2024-05-09 04:17:30 瀏覽:802
返校vlog腳本 發布:2024-05-09 04:15:53 瀏覽:619
vps雲伺服器免費租用 發布:2024-05-09 04:10:42 瀏覽:209
空調壓縮機排量 發布:2024-05-09 04:08:42 瀏覽:540
android使用靜態庫 發布:2024-05-09 04:05:40 瀏覽:214
原生安卓開機動畫在哪裡 發布:2024-05-09 03:52:19 瀏覽:395
微信收藏在哪個文件夾 發布:2024-05-09 03:47:03 瀏覽:827