本文整理了Java中android.app.ProgressDialog
类的一些代码示例,展示了ProgressDialog
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ProgressDialog
类的具体详情如下:
包路径:android.app.ProgressDialog
类名称:ProgressDialog
暂无
代码示例来源:origin: stackoverflow.com
switch (id) {
case progress_bar_type: // we set this to 0
pDialog = new ProgressDialog(this);
pDialog.setMessage("Downloading file. Please wait...");
pDialog.setIndeterminate(false);
pDialog.setMax(100);
pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
pDialog.setCancelable(true);
pDialog.show();
return pDialog;
default:
int lenghtOfFile = conection.getContentLength();
InputStream input = new BufferedInputStream(url.openStream(),
8192);
while ((count = input.read(data)) != -1) {
total += count;
input.close();
pDialog.setProgress(Integer.parseInt(progress[0]));
代码示例来源:origin: stackoverflow.com
mProgressDialog.setMessage("Downloading file..");
mProgressDialog.setIndeterminate(false);
mProgressDialog.setMax(100);
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mProgressDialog.setCancelable(true);
protected void onPreExecute() {
super.onPreExecute();
mProgressDialog.show();
URL u = new URL(aurl[0]);
HttpURLConnection c = (HttpURLConnection) u.openConnection();
c.setRequestMethod("GET");
c.setDoOutput(true);
c.connect();
int lenghtOfFile = c.getContentLength();
long total = 0;
while ((len1 = in.read(buffer)) > 0) {
mProgressDialog.setProgress(Integer.parseInt(progress[0]));
mProgressDialog.dismiss();
代码示例来源:origin: stackoverflow.com
protected void onPreExecute() {
super.onPreExecute();
dialog.setMessage("Please wait...");
dialog.setCanceledOnTouchOutside(false);
dialog.show();
protected void onPostExecute(String... result) {
try {
JSONObject jsonObject = new JSONObject(result[0]);
double lng = ((JSONArray)jsonObject.get("results")).getJSONObject(0)
.getJSONObject("geometry").getJSONObject("location")
.getDouble("lng");
double lat = ((JSONArray)jsonObject.get("results")).getJSONObject(0)
.getJSONObject("geometry").getJSONObject("location")
.getDouble("lat");
e.printStackTrace();
if (dialog.isShowing()) {
dialog.dismiss();
String response = "";
try {
url = new URL(requestURL);
代码示例来源:origin: stackoverflow.com
ProgressDialog progress = new ProgressDialog(this);
progress.setTitle("Loading");
progress.setMessage("Wait while loading...");
progress.setCancelable(false); // disable dismiss by tapping outside of the dialog
progress.show();
// To dismiss the dialog
progress.dismiss();
代码示例来源:origin: Justson/AgentWeb
@Override
public void onLoading(String msg) {
if (mProgressDialog == null) {
mProgressDialog = new ProgressDialog(mActivity);
}
mProgressDialog.setCancelable(false);
mProgressDialog.setCanceledOnTouchOutside(false);
mProgressDialog.setMessage(msg);
mProgressDialog.show();
}
代码示例来源:origin: Justson/AgentWeb
@Override
public void onCancelLoading() {
if (mProgressDialog != null && mProgressDialog.isShowing()) {
mProgressDialog.dismiss();
}
mProgressDialog = null;
}
代码示例来源:origin: stackoverflow.com
mPDialog = new ProgressDialog(context);
mPDialog.setMessage(dialogMessage);
mPDialog.setIndeterminate(true);
mPDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mPDialog.setCancelable(true);
mPDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
int fileLength = connection.getContentLength();
mWakeLock.acquire();
mPDialog.show();
super.onProgressUpdate(progress);
mPDialog.setIndeterminate(false);
mPDialog.setMax(100);
mPDialog.setProgress(progress[0]);
Log.i("DownloadTask", "Work Done! PostExecute");
mWakeLock.release();
mPDialog.dismiss();
if (result != null)
Toast.makeText(mContext,"Download error: "+result, Toast.LENGTH_LONG).show();
代码示例来源:origin: stackoverflow.com
protected void onPreExecute() {
super.onPreExecute();
mProgressDialog.setMessage("Downloading");
mProgressDialog.setIndeterminate(false);
mProgressDialog.setMax(100);
mProgressDialog.setCancelable(true);
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mProgressDialog.show();
InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new FileOutputStream(PATH+targetFileName);
byte data[] = new byte[1024];
long total = 0;
while ((count = input.read(data)) != -1) {
total += count;
publishProgress ((int)(total*100/lenghtOfFile));
input.close();
} catch (Exception e) {}
return null;
mProgressDialog.setProgress(progress[0]);
if(mProgressDialog.getProgress()==mProgressDialog.getMax()){
mProgressDialog.dismiss();
Toast.makeText(fa, "File Downloaded", Toast.LENGTH_SHORT).show();
代码示例来源:origin: stackoverflow.com
progressDialog.show();
protected Void doInBackground(String... arg0) {
try {
URL url = new URL(arg0[0]);
HttpURLConnection c = (HttpURLConnection) url.openConnection();
c.setRequestMethod("GET");
c.setDoOutput(true);
c.connect();
InputStream is = c.getInputStream();
while ((len1 = is.read(buffer)) != -1) {
fos.write(buffer, 0, len1);
is.close();
intent.setDataAndType(Uri.fromFile(new File(sdcard,"Android/data/com.mycompany.android.games/temp/temp.apk")), "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // without this flag android returned a intent error!
context.startActivity(intent);
progressDialog.dismiss();
if(status == 1)
Toast.makeText(context,"Game Not Available",Toast.LENGTH_LONG).show();
代码示例来源:origin: stackoverflow.com
protected void onPreExecute() {
dialog = new ProgressDialog(TheActivity.this);
dialog.setMessage("Uploading...");
dialog.setIndeterminate(false);
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
dialog.setProgress(0);
dialog.show();
fileInputStream.close();
URL url = new URL("some path");
HttpURLConnection connection =
(HttpURLConnection) url.openConnection();
OutputStream outputStream = connection.getOutputStream();
outputStream.flush();
InputStream inputStream = connection.getInputStream();
inputStream.close();
dialog.setProgress(progress[0]);
protected void onPostExecute(Void result) {
try {
dialog.dismiss();
} catch(Exception e) {
代码示例来源:origin: stackoverflow.com
protected void onPreExecute() {
pDialog = new ProgressDialog(MainActivity.this);
pDialog.setMessage("Attempting download...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
URL url = new URL(sourcepath);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.connect();
fileSize = connection.getContentLength();
InputStream inputStream = connection.getInputStream();
inputStream.close();
connection.disconnect();
pDialog.dismiss();
代码示例来源:origin: stackoverflow.com
final ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setTitle("Downloading Image ...");
progressDialog.setMessage("Download in progress ...");
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setProgress(0);
progressDialog.setMax(100);
progressDialog.show();
progressDialog.setProgress(100 * msg.arg1 / msg.arg2);
if (progressDialog.getProgress() == progressDialog.getMax()) {
progressDialog.dismiss();
public void run() {
try {
URL url = new URL("<your_url>");
HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.connect();
InputStream inputStream = urlConnection.getInputStream();
int totalSize = urlConnection.getContentLength();
ByteArrayOutputStream receivedBytesStream = new ByteArrayOutputStream();
int downloadedSize = 0;
byte[] buffer = new byte[1024];
int bufferLength = 0;
while ((bufferLength = inputStream.read(buffer)) > 0 ) {
receivedBytesStream.write(buffer, 0, bufferLength);
downloadedSize += bufferLength;
代码示例来源:origin: stackoverflow.com
String xmlUrl = urls[0];
URL u = new URL(xmlUrl);
HttpURLConnection c = (HttpURLConnection) u.openConnection();
c.setRequestMethod("GET");
c.setDoOutput(true);
c.connect();
int lengthOfFile = c.getContentLength();
InputStream in = c.getInputStream();
long total = 0;
while ((len1 = in.read(buffer)) > 0) {
switch (id) {
case DIALOG_DOWNLOAD_PROGRESS:
mProgressDialog = new ProgressDialog(this);
mProgressDialog.setMessage("Retrieving latest announcements...");
mProgressDialog.setIndeterminate(false);
代码示例来源:origin: stackoverflow.com
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(PolyMap.this);
pDialog.setMessage("Loading route. Please wait...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();
JSONObject jsonObject = new JSONObject(jsonOutput);
JSONArray routesArray = jsonObject.getJSONArray("routes");
JSONObject route = routesArray.getJSONObject(0);
JSONObject poly = route.getJSONObject("overview_polyline");
String polyline = poly.getString("points");
polyz = decodePoly(polyline);
pDialog.dismiss();
代码示例来源:origin: stackoverflow.com
super.onPreExecute();
pDialog = new ProgressDialog(signInScreen);
pDialog.setMessage(getString(R.string.please_wait));
pDialog.setCancelable(false);
pDialog.show();
protected String doInBackground(String... arg0) {
try {
URL url = new URL("http://192.168.1.57:80/TOTSphp/getAllUsersInfo.php");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("User-Agent", "TOTS");
conn.setDoOutput(true);
conn.setDoInput(true);
try {
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
conn.disconnect();
protected void onPostExecute(String email) {
if(pDialog.isShowing()) {
pDialog.dismiss();
代码示例来源:origin: stackoverflow.com
txtJson = (TextView) findViewById(R.id.tvJsonItem);
btnHit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
super.onPreExecute();
pd = new ProgressDialog(MainActivity.this);
pd.setMessage("Please wait");
pd.setCancelable(false);
pd.show();
URL url = new URL(params[0]);
connection = (HttpURLConnection) url.openConnection();
connection.connect();
InputStream stream = connection.getInputStream();
} finally {
if (connection != null) {
connection.disconnect();
protected void onPostExecute(String result) {
super.onPostExecute(result);
if (pd.isShowing()){
pd.dismiss();
代码示例来源:origin: stackoverflow.com
load_img = (Button)findViewById(R.id.load);
img = (ImageView)findViewById(R.id.img);
load_img.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(MainActivity.this);
pDialog.setMessage("Loading Image ....");
pDialog.show();
bitmap = BitmapFactory.decodeStream((InputStream)new URL(args[0]).getContent());
} catch (Exception e) {
e.printStackTrace();
if(image != null){
img.setImageBitmap(image);
pDialog.dismiss();
}else{
pDialog.dismiss();
Toast.makeText(MainActivity.this, "Image Does Not exist or Network Error", Toast.LENGTH_SHORT).show();
代码示例来源:origin: UdacityAndroidBasicsScholarship/scholar-quiz
@Override
protected void onPostExecute(String json) {
try {
progressDialog.dismiss();
JSONObject jsonObject = new JSONObject(json);
JSONArray jsonArray = jsonObject.getJSONArray("server_response");
JSONObject object = jsonArray.getJSONObject(0);
String code = object.getString("code");
String message = object.getString("message");
if(code.equals("reg_true")){
showDialog("Registration Successfull",message,code);
}else if(code.equals("reg_false")){
showDialog("Registration Failed",message,code);
}else if(code.equals("login_true")){
Intent intent = new Intent(activity,LessonActivity.class);
intent.putExtra("message",message);
activity.startActivity(intent);
sharedPreferenceConfig = new SharedPreferenceConfig(activity);
sharedPreferenceConfig.writeLoginStatus(true);
activity.finish();
}else if(code.equals("login_false")){
showDialog("Error in Login",message,code);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
代码示例来源:origin: stackoverflow.com
private ProgressDialog Dialog = new ProgressDialog(ABC.this);
Dialog.setMessage("Loading.....");
Dialog.show();
Dialog.dismiss();
Intent intent = new Intent(ABC.this, XYZ.class);
startActivity(intent);
JSONParser parser = new JSONParser();
JSONObject jsonObject = new JSONObject();
JSONArray aJson = jsonObject.getJSONFromUrl(url);
contacts = aJson.getJSONObject(TAG_CATEGORY);
String id = c.getString(CATEGORY_COLUMN_ID);
String title = c.getString(CATEGORY_COLUMN_TITLE);
String content = c.getString(CATEGORY_COLUMN_CONTENT);
e.printStackTrace();
代码示例来源:origin: curtis2/SuperVideoPlayer
public void handleMessage(Message msg) {
InitActivity ctx = (InitActivity) mContext.get();
switch (msg.what) {
case 0:
ctx.mPD.dismiss();
Intent src = ctx.getIntent();
Intent i = new Intent();
i.setClassName(src.getStringExtra("package"), src.getStringExtra("className"));
i.setData(src.getData());
i.putExtras(src);
i.putExtra(FROM_ME, true);
ctx.startActivity(i);
ctx.finish();
break;
}
}
}
内容来源于网络,如有侵权,请联系作者删除!