コード例 #1
0
  private void verifyBluetooth() {

    try {
      if (!BeaconManager.getInstanceForApplication(getApplicationContext()).checkAvailability()) {
        final AlertDialog.Builder builder = new AlertDialog.Builder(getApplicationContext());
        builder.setTitle("Bluetooth not enabled");
        builder.setMessage("Please enable bluetooth in settings and restart this application.");
        builder.setPositiveButton(android.R.string.ok, null);
        builder.setOnDismissListener(
            new DialogInterface.OnDismissListener() {
              @Override
              public void onDismiss(DialogInterface dialog) {
                System.exit(0);
              }
            });
        builder.show();
      }
    } catch (RuntimeException e) {
      final AlertDialog.Builder builder = new AlertDialog.Builder(getApplicationContext());
      builder.setTitle("Bluetooth LE not available");
      builder.setMessage("Sorry, this device does not support Bluetooth LE.");
      builder.setPositiveButton(android.R.string.ok, null);
      builder.setOnDismissListener(
          new DialogInterface.OnDismissListener() {

            @Override
            public void onDismiss(DialogInterface dialog) {
              System.exit(0);
            }
          });
      builder.show();
    }
  }
コード例 #2
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.framework);

    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    mPrefs.edit().putInt(PREFERENCE_CURRENT_ID, 0).commit();

    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setTitle(getString(R.string.app_title));

    mAdapter = new PageFragmentAdapter(getSupportFragmentManager());
    fConnect = new ConnectFragment();
    fConnect.setParent(this);
    fRecord = new RecordFragment();
    fRecord.setParent(this);
    mAdapter.addFragment(fConnect, "Connect");
    mAdapter.addFragment(fRecord, "Record");
    // mAdapter.addFragment(new StatusFragment(), "Status");

    mPager = (ViewPager) findViewById(R.id.view_pager);
    mPager.setAdapter(mAdapter);

    mTabLayout = (TabLayout) findViewById(R.id.tab_layout);
    mTabLayout.setupWithViewPager(mPager);

    if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
      Toast.makeText(this, "BLE not supported", Toast.LENGTH_SHORT).show();
      finish();
    }

    if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
        != PackageManager.PERMISSION_GRANTED) {
      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      builder.setTitle("File Access");
      builder.setMessage("Please enable the app to write external storage");
      builder.setPositiveButton(android.R.string.ok, null);
      builder.setOnDismissListener(
          new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
              requestPermissions(new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
            }
          });
      builder.show();
    }

    // mPlayer = MediaPlayer.create(this, R.raw.received);
  }
コード例 #3
0
 public void alertNoBeaconsSensed() {
   final AlertDialog.Builder builder = new AlertDialog.Builder(this);
   builder.setTitle("No Beacons in the region");
   builder.setMessage("There are no beacons sensed in the region.");
   builder.setPositiveButton(android.R.string.ok, null);
   builder.setOnDismissListener(
       new DialogInterface.OnDismissListener() {
         @Override
         public void onDismiss(DialogInterface dialog) {
           // finish();
           // System.exit(0);
         }
       });
   builder.show();
 }
コード例 #4
0
        @Override
        public void onItemClick(
            AdapterView<?> parent, View view, final int position, final long id) {

          if (dialogAlreadyShown) {
            return;
          }

          // remove touched item after confirmation
          DialogInterface.OnClickListener confirmationListener =
              new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                  switch (which) {
                    case DialogInterface.BUTTON_POSITIVE:
                      ipAddressList.remove(position);
                      saveList();
                      break;
                    case DialogInterface.BUTTON_NEGATIVE:
                      break;
                  }
                }
              };

          AlertDialog.Builder builder = new AlertDialog.Builder(CustomDevicesActivity.this);
          builder.setMessage("Delete " + ipAddressList.get(position) + " ?");
          builder.setPositiveButton("Yes", confirmationListener);
          builder.setNegativeButton("No", confirmationListener);

          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { // DismissListener
            dialogAlreadyShown = true;
            builder.setOnDismissListener(
                new DialogInterface.OnDismissListener() {
                  @Override
                  public void onDismiss(DialogInterface dialog) {
                    dialogAlreadyShown = false;
                  }
                });
          }

          builder.show();
        }
コード例 #5
0
ファイル: ViewGameActivity.java プロジェクト: Reline/Onigokko
  private void setLeaveGameButton() {

    final AlertDialog.Builder builder = new AlertDialog.Builder(ViewGameActivity.this);
    builder.setTitle(R.string.status);
    builder.setMessage(R.string.left_game_success);
    builder.setIcon(R.drawable.tag_ic_circle);
    builder.setNegativeButton(
        "OK",
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
          }
        });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
      builder.setOnDismissListener(
          new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
              finish();
            }
          });
    }

    leaveGameButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            String[] params = {
              Integer.toString(selectedGame.getID()), Player.currentPlayer.getGoogleID()
            };
            new LeaveGame() {
              @Override
              protected void onPostExecute(String result) {
                builder.show();
              }
            }.execute(params);
          }
        }); // setonclicklistener to leave game
  }
コード例 #6
0
  @CalledByNative
  private void onPolicyCheckedBeforeSignIn(String managementDomain) {
    if (managementDomain == null) {
      Log.d(TAG, "Account doesn't have policy");
      doSignIn();
      return;
    }

    if (mSignInActivity.isDestroyed()) {
      // The activity is no longer running, cancel sign in.
      cancelSignIn();
      return;
    }

    if (mPassive) {
      // If this is a passive interaction (e.g. auto signin) then don't show the confirmation
      // dialog.
      nativeFetchPolicyBeforeSignIn(mNativeSigninManagerAndroid);
      return;
    }

    Log.d(TAG, "Account has policy management");
    AlertDialog.Builder builder = new AlertDialog.Builder(mSignInActivity);
    builder.setTitle(R.string.policy_dialog_title);
    builder.setMessage(
        mContext.getResources().getString(R.string.policy_dialog_message, managementDomain));
    builder.setPositiveButton(
        R.string.policy_dialog_proceed,
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int id) {
            Log.d(TAG, "Accepted policy management, proceeding with sign-in");
            // This will call back to onPolicyFetchedBeforeSignIn.
            nativeFetchPolicyBeforeSignIn(mNativeSigninManagerAndroid);
            mPolicyConfirmationDialog = null;
          }
        });
    builder.setNegativeButton(
        R.string.policy_dialog_cancel,
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int id) {
            Log.d(TAG, "Cancelled sign-in");
            cancelSignIn();
            mPolicyConfirmationDialog = null;
          }
        });
    builder.setOnDismissListener(
        new DialogInterface.OnDismissListener() {
          @Override
          public void onDismiss(DialogInterface dialog) {
            if (mPolicyConfirmationDialog != null) {
              Log.d(TAG, "Policy dialog dismissed, cancelling sign-in.");
              cancelSignIn();
              mPolicyConfirmationDialog = null;
            }
          }
        });
    mPolicyConfirmationDialog = builder.create();
    mPolicyConfirmationDialog.show();
  }
コード例 #7
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    k = 0;
    setContentView(R.layout.activity_main);
    progressBar = (ProgressBar) findViewById(R.id.progresbar);
    progressBar.setVisibility(View.VISIBLE);
    // -----------------------------------------
    // nothing!!
    ObservableScrollView scrollview = (ObservableScrollView) findViewById(R.id.scrollview);
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.next);
    fab.attachToScrollView(scrollview);
    ll = (LinearLayout) findViewById(R.id.ll2);

    quizname = getIntent().getStringExtra("quizname");
    url = getIntent().getStringExtra("URI");
    totalq = getIntent().getStringExtra("totalq");

    // ------------------------------------------

    toolbar = (Toolbar) findViewById(R.id.app_bar);
    toolbar.setTitleTextColor(getResources().getColor(R.color.white));
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.teal)));
    actionBar.setTitle("ORGANIC CHEMISTRY ");
    toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.ic_back_white));
    toolbar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onBackPressed(); // PB in Gap-by default given//do something
          }
        });
    // --------------------------------------------

    /*  ActionBar bar = getActionBar();
    bar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.actionbar_background)));*/

    // -------------------------------------------------------------

    imageLoader = AppController.getInstance().getImageLoader();

    timer = (TextView) findViewById(R.id.timer);
    cor = (TextView) findViewById(R.id.tcorrect);
    inc = (TextView) findViewById(R.id.incorrect);
    tot = (TextView) findViewById(R.id.tot);

    Typeface myTypeface = Typeface.createFromAsset(getAssets(), "fonts/pie.ttf");
    /* cor.setTypeface(myTypeface);
    inc.setTypeface(myTypeface);
    tot.setTypeface(myTypeface);*/

    t1 = (RadioButton) findViewById(R.id.t1);
    t2 = (RadioButton) findViewById(R.id.t2);
    t3 = (RadioButton) findViewById(R.id.t3);
    t4 = (RadioButton) findViewById(R.id.t4);
    question = (TextView) findViewById(R.id.question);

    v1 = (ImageView) findViewById(R.id.v1);
    v2 = (ImageView) findViewById(R.id.v2);
    v3 = (ImageView) findViewById(R.id.v3);
    v4 = (ImageView) findViewById(R.id.v4);
    questionimage = (ImageView) findViewById(R.id.questionimage);
    questionimage2 = (ImageView) findViewById(R.id.questionimage2);
    questionimage3 = (ImageView) findViewById(R.id.questionimage3);
    questionimage4 = (ImageView) findViewById(R.id.questionimage4);

    qiarr = new ImageView[] {questionimage, questionimage2, questionimage3, questionimage4};

    next = (FloatingActionButton) findViewById(R.id.next);
    next.setOnClickListener(this);

    t1.setOnCheckedChangeListener(this);
    t2.setOnCheckedChangeListener(this);
    t3.setOnCheckedChangeListener(this);
    t4.setOnCheckedChangeListener(this);

    AlertDialog.Builder builder1;

    // AlertDialog.Builder builder;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      builder1 =
          new AlertDialog.Builder(
              this, android.R.style.Theme_Material_Light_Dialog_Alert); // theme problem
    } else {
      builder1 = new AlertDialog.Builder(this);
    }
    builder1.setTitle("Test Information");
    builder1.setMessage(
        "This test would have "
            + totalq
            + " questions and you would get 1 minute for each question. All the best! ;)");
    builder1.setCancelable(true); // change
    builder1.setNeutralButton(
        android.R.string.ok,
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
            getdata();
          }
        });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
      builder1.setOnDismissListener(
          new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
              getdata();
              Log.d("ondismiss", "dismissed");
            }
          });
    }
    AlertDialog alert11 = builder1.create();
    alert11.show();
  }