Thursday, November 24, 2016

Android : Rotating Progress Box

Rotating Progress Box

import android.Manifest;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Handler;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Toast;


public void progress_box()  {
    final ProgressDialog  progressDialog = new ProgressDialog(this);
    progressDialog.setIndeterminate(true);
    progressDialog.setMessage("Logging in ...");
    progressDialog.show();
    Runnable progressRunnable = new Runnable() {
        @Override        public void run() {
            progressDialog.cancel();
            new misc().alert_box("Error !","No Internet Connection Available",MainActivity.this);
        }
    };
    Handler pdCanceller = new Handler();
    pdCanceller.postDelayed(progressRunnable, 2000);

}
 
 
 
Make sure the following codes is present in build.gradle (Module:app) file :

apply plugin: 'com.android.application'
android {
    compileSdkVersion 24    buildToolsVersion "24.0.3"    defaultConfig {
        applicationId "com.example.dejayapr.test1"        minSdkVersion 15        targetSdkVersion 24        versionCode 1        versionName "1.0"        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"    }
    buildTypes {
        release {
            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'        }
    }
    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'    })
    compile 'com.android.support:appcompat-v7:24.2.1'    compile 'com.android.support:design:24.2.1'    testCompile 'junit:junit:4.12'}

No comments:

Post a Comment