<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Feeling

        三人行,必有我師焉

       ::  :: 新隨筆 :: 聯系 ::  :: 管理 ::
      185 隨筆 :: 0 文章 :: 392 評論 :: 0 Trackbacks
    獲取屏幕Display: Activity.getWindowManager().getDefaultDisplay();
    獲取擴展存儲目錄:Environment.getExternalStorageDirectory()
    通過文件獲取Uri:Uri.fromFile(File)
    根據文件路徑獲取圖片:BitmapFactory.decodeFile(imageFilePath, bmpFactoryOptions)
    獲取相機Intent:new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    獲取相機拍照后的圖片:
    Bundle extras = intent.getExtras();
    Bitmap bmp = (Bitmap) extras.get("data");
    觸摸事件:onTouchEvent(MotionEvent ev)
    媒體播放器:android.media.MediaPlayer
    媒體控制器:android.widget.MediaController(和播放器不在同一個package下)
    SurfaceView是視圖(View)的繼承類,這個視圖里內嵌了一個專門用于繪制的Surface,類似于Canvas,但感覺比Canvas更高級。
    android.provider.MediaStore里包含了相關的Image,Video,Audio信息,可通過managedQuery方法來查詢和遍歷。
    Android中的AdapterView使用Adapter來獲取數據,和JFace中的ContentProvider對應。
    根據字符串路徑獲取Uri:
    Uri.parse((String)Path)
    封裝好的視頻View:android.widget.VideoView
    視頻錄制:android.media.MediaRecorder
    相機高畫質:CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);


    設置透明度(這是窗體本身的透明度,非背景)

    WindowManager.LayoutParams lp=getWindow().getAttributes();
                    lp.alpha=0.3f;
                  getWindow().setAttributes(lp);
                    
    alpha在0.0f到1.0f之間。1.0完全不透明,0.0f完全透明


    設置黑暗度

                    WindowManager.LayoutParams lp=getWindow().getAttributes();
                    lp.dimAmount=0.5f;
                    getWindow().setAttributes(lp);
                    getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);

    dimAmount在0.0f和1.0f之間,0.0f完全不暗,1.0f全暗


    設置背景模糊

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,     
               WindowManager.LayoutParams.FLAG_BLUR_BEHIND);



    //調用瀏覽器 
    Uri uri = Uri.parse(""); 
    Intent it = new Intent(Intent.ACTION_VIEW,uri); 
    startActivity(it); 

    //顯示某個坐標在地圖上 
    Uri uri = Uri.parse("geo:38.899533,-77.036476"); 
    Intent it = new Intent(Intent.Action_VIEW,uri); 
    startActivity(it); 

    //顯示路徑 
    Uri uri = Uri.parse("http://maps.google.com/maps?f=d&saddr=startLat%20startLng&daddr=endLat%20endLng&hl=en"); 
    Intent it = new Intent(Intent.ACTION_VIEW,URI); 
    startActivity(it); 

    //撥打電話 
    Uri uri = Uri.parse("tel:10086"); 
    Intent it = new Intent(Intent.ACTION_DIAL, uri); 
    startActivity(it); 

    Uri uri = Uri.parse("tel.10086"); 
    Intent it =new Intent(Intent.ACTION_CALL,uri); 
    //需要添加 <uses-permission id="android.permission.CALL_PHONE" /> 這個權限到androidmanifest.xml 

    //發送短信或彩信 
    Intent it = new Intent(Intent.ACTION_VIEW); 
    it.putExtra("sms_body", "The SMS text"); 
    it.setType("vnd.android-dir/mms-sms"); 
    startActivity(it); 

    //發送短信 
    Uri uri = Uri.parse("smsto:10086"); 
    Intent it = new Intent(Intent.ACTION_SENDTO, uri); 
    it.putExtra("sms_body", "cwj"); 
    startActivity(it); 

    //發送彩信 
    Uri uri = Uri.parse("content://media/external/images/media/23"); 
    Intent it = new Intent(Intent.ACTION_SEND); 
    it.putExtra("sms_body", "some text"); 
    it.putExtra(Intent.EXTRA_STREAM, uri); 
    it.setType("image/png"); 
    startActivity(it); 

    //發送郵件 
    Uri uri = Uri.parse("mailto:android123@163.com"); 
    Intent it = new Intent(Intent.ACTION_SENDTO, uri); 
    startActivity(it); 

    Intent it = new Intent(Intent.ACTION_SEND); 
    it.putExtra(Intent.EXTRA_EMAIL, android123@163.com); 
    it.putExtra(Intent.EXTRA_TEXT, "The email body text"); 
    it.setType("text/plain"); 
    startActivity(Intent.createChooser(it, "Choose Email Client")); 

    Intent it=new Intent(Intent.ACTION_SEND); 
    String[] tos={"me@abc.com"}; 
    String[] ccs={"you@abc.com"}; 
    it.putExtra(Intent.EXTRA_EMAIL, tos); 
    it.putExtra(Intent.EXTRA_CC, ccs); 
    it.putExtra(Intent.EXTRA_TEXT, "The email body text"); 
    it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text"); 
    it.setType("message/rfc822"); 
    startActivity(Intent.createChooser(it, "Choose Email Client")); 

    //播放媒體文件 
    Intent it = new Intent(Intent.ACTION_VIEW); 
    Uri uri = Uri.parse("file:///sdcard/cwj.mp3"); 
    it.setDataAndType(uri, "audio/mp3"); 
    startActivity(it); 

    Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1"); 
    Intent it = new Intent(Intent.ACTION_VIEW, uri); 
    startActivity(it); 

    //卸載APK 
    Uri uri = Uri.fromParts("package", strPackageName, null); 
    Intent it = new Intent(Intent.ACTION_DELETE, uri); 
    startActivity(it); 

    //卸載apk 2 
    Uri uninstallUri = Uri.fromParts("package", "xxx", null); 
    returnIt = new Intent(Intent.ACTION_DELETE, uninstallUri); 

    //安裝APK 
    Uri installUri = Uri.fromParts("package", "xxx", null); 
    returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri); 

    //播放音樂 
    Uri playUri = Uri.parse("file:///sdcard/download/sth.mp3"); 
    returnIt = new Intent(Intent.ACTION_VIEW, playUri); 

    //發送附近 
    Intent it = new Intent(Intent.ACTION_SEND); 
    it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text"); 
    it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/cwj.mp3"); 
    sendIntent.setType("audio/mp3"); 
    startActivity(Intent.createChooser(it, "Choose Email Client")); 

    //market上某個應用信,pkg_name就是應用的packageName 
    Uri uri = Uri.parse("market://search?q=pname:pkg_name"); 
    Intent it = new Intent(Intent.ACTION_VIEW, uri); 
    startActivity(it); 

    //market上某個應用信息,app_id可以通過www網站看下 
    Uri uri = Uri.parse("market://details?id=app_id"); 
    Intent it = new Intent(Intent.ACTION_VIEW, uri); 
    startActivity(it); 

    //調用搜索 
    Intent intent = new Intent(); 
    intent.setAction(Intent.ACTION_WEB_SEARCH); 
    intent.putExtra(SearchManager.QUERY,"android123") 
    startActivity(intent); 

    //調用分享菜單 
    Intent intent=new Intent(Intent.ACTION_SEND); 
    intent.setType("text/plain"); //分享的數據類型 
    intent.putExtra(Intent.EXTRA_SUBJECT, "subject"); //主題 
    intent.putExtra(Intent.EXTRA_TEXT, "content"); //內容 
    startActivity(Intent.createChooser(intent, "title")); //目標應用選擇對話框的標題


    獲取Location:
    Criteria criteria = new Criteria();
    criteria.setAccuracy(Criteria.ACCURACY_COARSE);
    criteria.setPowerRequirement(Criteria.POWER_LOW);
    LocationManager locManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    if(locManager.getBestProvider(criteria, true) != null)
    myLocation = locManager.getLastKnownLocation(locManager.getBestProvider(criteria, true));
    else {
    myLocation = new Location("gps");
    myLocation.setLatitude(47.100301);
    myLocation.setLongitude(-119.982465);
    }
    posted on 2012-05-05 19:41 三人行,必有我師焉 閱讀(850) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    GitHub |  開源中國社區 |  maven倉庫 |  文件格式轉換 
    主站蜘蛛池模板: 99热这里只有精品免费播放| 亚洲五月午夜免费在线视频| 无码国产精品一区二区免费式直播 | a在线免费观看视频| 国产91精品一区二区麻豆亚洲| 黄色一级毛片免费| 亚洲午夜精品久久久久久浪潮 | 在线日韩日本国产亚洲| sss日本免费完整版在线观看| 亚洲毛片av日韩av无码| A毛片毛片看免费| 亚洲色精品88色婷婷七月丁香| 一级一级一片免费高清| 亚洲精品无码久久毛片| a毛片全部播放免费视频完整18| 亚洲成Av人片乱码色午夜| 大地资源在线观看免费高清| 国产成人精品亚洲2020| 日本免费中文字幕在线看| 四虎影视久久久免费| 国产精品亚洲а∨无码播放| 777成影片免费观看| 亚洲AV无码一区二区三区在线 | 亚洲国产黄在线观看| 91国内免费在线视频| 亚洲视频在线不卡| 高清国语自产拍免费视频国产| 国产成人无码综合亚洲日韩| 日韩中文字幕免费视频| 国产精品高清视亚洲精品| 免费国产综合视频在线看| 成在人线av无码免费高潮喷水 | 免费看又黄又爽又猛的视频软件| 久久久久噜噜噜亚洲熟女综合 | 一级毛片免费毛片一级毛片免费| 久久久久亚洲精品天堂久久久久久| a毛看片免费观看视频| 亚洲av无码国产综合专区| 波多野结衣中文一区二区免费| 国产午夜无码精品免费看 | 久久亚洲2019中文字幕|