傳知_16_android

來源:互聯網
上載者:User

組件

Activity

ContentProvider

BroadcastReceiver

服務

 

意圖用於 啟用 各種組件的

 

 

輸入以下命令再開啟一個Android模擬器:

  emulator -data itcast 

 

 

一個Activity調用另一個Activity:

public void onClick(View v) {

Intent  in = new Intent(ex12.this ,  rgActivity.class) ;

startActivityForRecult(in ,  RG_REQUEST) ;

}

 

地圖功能:

extends MapActivity

 

撥號

<uses-permission android:name="android.permission.CALL_PHONE"/>

 

LinearLayout (線性布局)、AbsoluteLayout(絕對布局)、RelativeLayout(相對布局)、TableLayout(表格版面配置)、FrameLayout(幀布局)

 

Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"+ editText.getText()));

                DialerAction.this.startActivity(intent);

 

內部類使用final ,防止其他類繼承

 

SMS

<uses-permission android:name="android.permission.SEND_SMS"/>

SmsManager smsManager = SmsManager.getDefault();

smsManager.sendTextMessage(mobile, null, msg, sentIntent, null);

          //最後二個參數為簡訊已發送的廣播意圖,最後一個參數為簡訊對方已收到簡訊的廣播意圖

//第二個參數是簡訊終生地址

Toast.makeText(SMSSender.this, "簡訊發送完成", Toast.LENGTH_LONG).show();

 

狀態列通知

對話方塊通知

吐西通知

 

htmlView

webview.setSettings.setJavaScriptEnabled(true) ;

webview.addJavascriptInterface(obj , "tacast") ;

js:itcast     //在an droid裡調用其js對象

webview.loadUrl("file:///android_asset/index.html");

jsondata = [{1,23,43,65,45},{ ... },{ ...  }] ;

var jsonobject = eval(jsondata) ;               //把字串轉換為json對象

 

webview.loadUrl("javascript:show()") ;            //

 

編碼顯示UI

LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(

                    ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

        linearLayout.addView(textView, params);

       

        params = new LinearLayout.LayoutParams(

                    ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);

        setContentView(linearLayout, params);

 

單元測試

<uses-library android:name="android.test.runner" />

<instrumentation android:name="android.test.InstrumentationTestRunner"

  android:targetPackage="cn.itcast.action" android:label="Tests for My App" />

日誌資訊

Log.i(TAG

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.