呼叫手機照相和相簿來顯示個人信心頭像並上傳至伺服器

2021-07-30 07:41:00 字數 1305 閱讀 2852

public class mainactivity extends activity 

});} /**

* 顯示修改頭像的對話方塊

*/protected void showchoosepicdialog() ;

builder.setnegativebutton("取消", null);

builder.setitems(items, new dialoginte***ce.onclicklistener()

}});

builder.create().show();

} @override

protected void onactivityresult(int requestcode, int resultcode, intent data)

break;

}} }

/*** 裁剪方法實現

* * @param uri

*/protected void startphotozoom(uri uri)

tempuri = uri;

intent intent = new intent("com.android.camera.action.crop");

intent.setdataandtype(uri, "image/*");

// 設定裁剪

intent.putextra("crop", "true");

// aspectx aspecty 是寬高的比例

intent.putextra("aspectx", 1);

intent.putextra("aspecty", 1);

// outputx outputy 是裁剪寬高

intent.putextra("outputx", 150);

intent.putextra("outputy", 150);

intent.putextra("return-data", true);

startactivityforresult(intent, crop_small_picture);

} /**

* 儲存裁剪之後的資料

* * @param

* * @param picdata

*/protected void setimagetoview(intent data)

} private void uploadpic(bitmap bitmap)

}}

上傳 頭像檔案用file上傳

file f = new file(imagepath)

上傳格式

HTML5呼叫手機攝像機 相簿功能

input標籤 type值為file,可以呼叫系統預設的照相機 相簿 攝像機 錄音功能。先上 accept表示開啟的系統檔案目錄 capture表示的是系統所捕獲的預設裝置,camera 照相機 camcorder 攝像機 microphone 錄音 其中還有乙個屬性multiple,支援多選,當支...

呼叫手機震動

1,在androidmanifest.xml中加入如下,取得許可權 2,private vibrator vibrator if float.parsefloat pricevalues cost off on off on.vibrator.vibrate pattern,1 1不重複,非 1為從...

WebApp呼叫手機相簿或攝像頭 撥打電話

最近在做乙個專案,需到用到開啟手機相簿 拍照和撥打 功能 開啟相簿 accept 屬性只能與 配合使用 它規定能夠通過檔案上傳進行提交的檔案型別 可以接受 gif 和 jpeg 兩種影象 如果不限制影象的格式,可以寫為 accept image 開啟相機 capture 屬性表示需要使用的系統功能 ...