首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

android_惯用API

2012-08-24 
android_常用API打电话, 文件读取与写入 ,共享偏好 ,手机中的html页面操纵启动Android内置的拨号程序-----

android_常用API
打电话, 文件读取与写入 ,共享偏好 ,手机中的html页面操纵


启动Android内置的拨号程序------------打电话啦




----------------------------
共享偏好对象---相当于java中的properties ,就是键值对

main.xml中有专门的webView来弄xml

public class JSHandler {private Context context;private WebView webView;private Handler handler;public JSHandler(Context context,Handler handler){this.context = context;this.handler = handler;webView = (WebView)((Activity)context).findViewById(R.id.webView);}//在java中调用js的方法,并往js传递数据public void show(){handler.post(new Runnable() {@Overridepublic void run() {webView.loadUrl("javascript:contactlist('"+query()+"')");}});}public void call(final String phone){handler.post(new Runnable() {@Overridepublic void run() {Toast.makeText(context, "hhh", 0).show();context.startActivity(new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+phone)));}});}public String query(){JSONObject jsonObject = new JSONObject();JSONObject jsonObject2 = new JSONObject();JSONArray arr = new JSONArray();try {jsonObject.put("id", 56);jsonObject.put("name", "老张");jsonObject.put("phone", "5556");jsonObject2.put("id", 89);jsonObject2.put("name", "老放");jsonObject2.put("phone", "5558");arr.put(jsonObject);arr.put(jsonObject2);} catch (JSONException e) {}return arr.toString();}}


-------------------------
------------------------








热点排行