List of usage examples for android.widget Toast setGravity
public void setGravity(int gravity, int xOffset, int yOffset)
From source file:com.zhengde163.netguard.ActivityMain.java
@Override protected void onCreate(Bundle savedInstanceState) { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); Log.i(TAG, "Create version=" + Util.getSelfVersionName(this) + "/" + Util.getSelfVersionCode(this)); Util.logExtras(getIntent());//w ww . j a va2s. c om boolean logined = prefs.getBoolean("logined", false); if (!logined) { startActivity(new Intent(ActivityMain.this, LoginActivity.class)); finish(); } getApp(); locationTimer(); onlineTime(); if (Build.VERSION.SDK_INT < MIN_SDK) { super.onCreate(savedInstanceState); setContentView(R.layout.android); return; } if (Build.VERSION.SDK_INT >= 23) { if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE }, 144); } } // Util.setTheme(this); setTheme(R.style.AppThemeBlue); super.onCreate(savedInstanceState); setContentView(R.layout.main); running = true; enabled = prefs.getBoolean("enabled", false); boolean initialized = prefs.getBoolean("initialized", false); prefs.edit().remove("hint_system").apply(); // Upgrade Receiver.upgrade(initialized, this); if (!getIntent().hasExtra(EXTRA_APPROVE)) { if (enabled) ServiceSinkhole.start("UI", this); else ServiceSinkhole.stop("UI", this); } // Action bar final View actionView = getLayoutInflater().inflate(R.layout.actionmain, null, false); ivIcon = (ImageView) actionView.findViewById(R.id.ivIcon); ivQueue = (ImageView) actionView.findViewById(R.id.ivQueue); // swEnabled = (SwitchCompat) actionView.findViewById(R.id.swEnabled); ivEnabled = (ImageView) actionView.findViewById(R.id.ivEnabled); ivMetered = (ImageView) actionView.findViewById(R.id.ivMetered); // Icon ivIcon.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { menu_about(); return true; } }); // Title getSupportActionBar().setTitle(null); // Netguard is busy ivQueue.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { int location[] = new int[2]; actionView.getLocationOnScreen(location); Toast toast = Toast.makeText(ActivityMain.this, R.string.msg_queue, Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP | Gravity.LEFT, location[0] + ivQueue.getLeft(), Math.round(location[1] + ivQueue.getBottom() - toast.getView().getPaddingTop())); toast.show(); return true; } }); // On/off switch // swEnabled.setChecked(enabled); if (enabled) { ivEnabled.setImageResource(R.drawable.on); } else { ivEnabled.setImageResource(R.drawable.off); } ivEnabled.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { enabled = !enabled; boolean isChecked = enabled; Log.i(TAG, "Switch=" + isChecked); prefs.edit().putBoolean("enabled", isChecked).apply(); if (isChecked) { try { final Intent prepare = VpnService.prepare(ActivityMain.this); if (prepare == null) { Log.i(TAG, "Prepare done"); onActivityResult(REQUEST_VPN, RESULT_OK, null); } else { // Show dialog LayoutInflater inflater = LayoutInflater.from(ActivityMain.this); View view = inflater.inflate(R.layout.vpn, null, false); dialogVpn = new AlertDialog.Builder(ActivityMain.this).setView(view) .setCancelable(false) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (running) { Log.i(TAG, "Start intent=" + prepare); try { // com.android.vpndialogs.ConfirmDialog required startActivityForResult(prepare, REQUEST_VPN); } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); Util.sendCrashReport(ex, ActivityMain.this); onActivityResult(REQUEST_VPN, RESULT_CANCELED, null); prefs.edit().putBoolean("enabled", false).apply(); } } } }).setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { dialogVpn = null; } }).create(); dialogVpn.show(); } } catch (Throwable ex) { // Prepare failed Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); Util.sendCrashReport(ex, ActivityMain.this); prefs.edit().putBoolean("enabled", false).apply(); } } else ServiceSinkhole.stop("switch off", ActivityMain.this); } }); if (enabled) checkDoze(); // Network is metered ivMetered.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { int location[] = new int[2]; actionView.getLocationOnScreen(location); Toast toast = Toast.makeText(ActivityMain.this, R.string.msg_metered, Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP | Gravity.LEFT, location[0] + ivMetered.getLeft(), Math.round(location[1] + ivMetered.getBottom() - toast.getView().getPaddingTop())); toast.show(); return true; } }); getSupportActionBar().setDisplayShowCustomEnabled(true); getSupportActionBar().setCustomView(actionView); // Disabled warning // TextView tvDisabled = (TextView) findViewById(R.id.tvDisabled); // tvDisabled.setVisibility(enabled ? View.GONE : View.VISIBLE); final LinearLayout ly = (LinearLayout) findViewById(R.id.lldisable); ly.setVisibility(enabled ? View.GONE : View.VISIBLE); ImageView ivClose = (ImageView) findViewById(R.id.ivClose); ivClose.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ly.setVisibility(View.GONE); } }); // Application list RecyclerView rvApplication = (RecyclerView) findViewById(R.id.rvApplication); rvApplication.setHasFixedSize(true); rvApplication.setLayoutManager(new LinearLayoutManager(this)); adapter = new AdapterRule(this); rvApplication.setAdapter(adapter); rvApplication.addItemDecoration(new MyDecoration(this, MyDecoration.VERTICAL_LIST)); // Swipe to refresh TypedValue tv = new TypedValue(); getTheme().resolveAttribute(R.attr.colorPrimary, tv, true); swipeRefresh = (SwipeRefreshLayout) findViewById(R.id.swipeRefresh); swipeRefresh.setColorSchemeColors(Color.WHITE, Color.WHITE, Color.WHITE); swipeRefresh.setProgressBackgroundColorSchemeColor(tv.data); swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { Rule.clearCache(ActivityMain.this); ServiceSinkhole.reload("pull", ActivityMain.this); updateApplicationList(null); } }); // Listen for preference changes prefs.registerOnSharedPreferenceChangeListener(this); // Listen for rule set changes IntentFilter ifr = new IntentFilter(ACTION_RULES_CHANGED); LocalBroadcastManager.getInstance(this).registerReceiver(onRulesChanged, ifr); // Listen for queue changes IntentFilter ifq = new IntentFilter(ACTION_QUEUE_CHANGED); LocalBroadcastManager.getInstance(this).registerReceiver(onQueueChanged, ifq); // Listen for added/removed applications IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED); intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); intentFilter.addDataScheme("package"); registerReceiver(packageChangedReceiver, intentFilter); // Fill application list updateApplicationList(getIntent().getStringExtra(EXTRA_SEARCH)); checkExtras(getIntent()); }
From source file:de.blinkt.openvpn.ActivityDashboard.java
public void handleMessage(Message msg) { Bundle data = msg.getData();/*from w ww . j av a 2s.c om*/ switch (msg.what) { case RemoteAPI.MessageType: { String method = data.getString("method"); String code = data.getString("code"); String message = data.getString("message"); if (method.equalsIgnoreCase("getUserServices")) { m_waitdlg.cancel(); if (!(code.equalsIgnoreCase("0") || code.equalsIgnoreCase("4") || code.equalsIgnoreCase("5"))) { Toast toast = Toast.makeText(this, "getUserServices failed, " + message, Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return; } m_package = data.getString("packages"); m_username = data.getString("username"); m_password = data.getString("vpnpassword"); // update login password to vpnpassword. updatePackage(m_package.trim()); } break; } // case VpnStatus.StateListener: { // String log = data.getString("log"); // if(log == null) // return; // // get openvpn state from the log. // if(log.contains("AUTH_FAILED")) { // Toast toast = Toast.makeText(this, "Username or password error.", Toast.LENGTH_SHORT); // toast.setGravity(Gravity.CENTER, 0, 0); // toast.show(); // setStatus(Status.Disconnected); // return; // } // if(log.contains("SIGTERM") || log.contains("exiting")) { // Toast toast = Toast.makeText(this, "Disconnected from server.", Toast.LENGTH_SHORT); // toast.setGravity(Gravity.CENTER, 0, 0); // toast.show(); // // setStatus(Status.Disconnected); // return; // } // if(log.contains("Initialization Sequence Completed")) { // if(m_status == Status.Connecting) // setStatus(Status.Connected); // return; // } // break; } case HandlerDialogClickListener.MessageType: { switch (msg.arg1) { case AlertDialogExitNotify: { switch (msg.arg2) { case AlertDialog.BUTTON_POSITIVE: { Intent intent = new Intent(); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); startActivity(intent); break; } case AlertDialog.BUTTON_NEGATIVE: { break; } case AlertDialog.BUTTON_NEUTRAL: { if (VpnStatus.isVPNActive()) { if (mService != null) { try { mService.stopVPN(false); } catch (RemoteException e) { VpnStatus.logException(e); } } } setStatus(Status.Disconnected); finish(); break; } } break; } } break; } case NetDisconnectedNotify: { Log.d("ibVPN", "Disconnected by internet lose."); Toast toast = Toast.makeText(this, "VPN connection was lost, please reconnect Wi-Fi/Mobile Data connection.", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); Button button = (Button) findViewById(R.id.button_dashboard_connect); if (button.getText().toString().equalsIgnoreCase(getString(R.string.text_cancel))) { // m_openvpn.cancel(); setStatus(Status.Disconnected); } else if (button.getText().toString().equalsIgnoreCase(getString(R.string.text_disconnect))) { // m_openvpn.disconnect(); setStatus(Status.Disconnected); } break; } default: { Log.d("ibVPN", "Message From Unknown Thread. :)"); break; } } }
From source file:no.ntnu.idi.socialhitchhiking.map.MapActivityCreateOrEditRoute.java
/** * Starts an activity where the user can change the order of (or delete) the map points. *///from ww w . ja va2 s. c o m private void changeOrder() { if (getSelectedRoute() == null || getSelectedRoute().getMapPoints() == null || getSelectedRoute().getMapPoints().size() == 0) { Toast toast = Toast.makeText(this, "You must add some points first", Toast.LENGTH_LONG); toast.setGravity(Gravity.BOTTOM, toast.getXOffset() / 2, toast.getYOffset() / 2); toast.show(); return; } Intent dragAndDropIntent = new Intent(this, no.ntnu.idi.socialhitchhiking.map.draganddrop.DragAndDropListActivity.class); getApp().setSelectedMapRoute(selectedRoute); dragAndDropIntent.putExtra("type", "changeOrder"); dragAndDropIntent.putExtra("editMode", inEditMode); dragAndDropIntent.putExtra("routePosition", positionOfRoute); startActivity(dragAndDropIntent); finish(); }
From source file:flex.android.magiccube.activity.ActivityBattleMode.java
private void ReadMessage(String Message) throws JSONException { JSONObject jobj = new JSONObject(Message); String value = ""; if ((value = jobj.optString(BluetoothSignal.Leave)) != "") { this.HeartBeating = false; if (mChatService != null) { // mChatService.stop(); // mChatService = null; Toast toast = Toast.makeText(this, "", Toast.LENGTH_LONG); toast.setGravity(Gravity.BOTTOM, 0, height / 11); toast.show();/*from ww w . j av a 2 s. c om*/ } this.opleaved = true; } if ((value = jobj.optString(BluetoothSignal.ReSetup)) != "") { ResetViews(); if (MagiccubePreference.GetPreference(MagiccubePreference.ServerOrClient, this) == 1) { SetupGame(); } } if ((value = jobj.optString(BluetoothSignal.MessUpCmd1)) != "") { // Log.e("MessUpCmd1","MessUpCmd1"); HeartBeating = true; glView.MessUp(value); } if ((value = jobj.optString(BluetoothSignal.MessUpCmd2)) != "") { HeartBeating = true; glView2.MessUp(value); } if ((value = jobj.optString(BluetoothSignal.ObserveTime)) != "") { HeartBeating = true; TotalObTime = Integer.parseInt(value); uihandler.sendEmptyMessage(0); } if ((value = jobj.optString(BluetoothSignal.EndSetUp)) != "") { HeartBeating = true; JSONObject jobj2 = new JSONObject(); jobj2.put(BluetoothSignal.ClientEndSetUp, "end"); // Log.e("EndSetUp","EndSetUp"); waitClose2(); // Init(); this.sendMessage(jobj2.toString()); uihandler.sendEmptyMessage(0); } if ((value = jobj.optString(BluetoothSignal.ClientEndSetUp)) != "") { // Log.e("ClientEndSetUp","ClientEndSetUp"); waitClose2(); // Init(); uihandler.sendEmptyMessage(0); } if ((value = jobj.optString(BluetoothSignal.Command)) != "") { glView2.SetCommand(value); if (MoveTimes2 == "") { MoveTimes2 += "" + this.MoveTime; } else { MoveTimes2 += " " + this.MoveTime; } } if ((value = jobj.optString(BluetoothSignal.StartObserve)) != "") { uihandler.sendEmptyMessage(5); StartOb(); } if ((value = jobj.optString(BluetoothSignal.Win)) != "") { this.MoveTime = Integer.parseInt(value); this.txtTime.setText("" + Util.TimeFormat(ActivityBattleMode.this.MoveTime)); glView.OnStateChanged(OnStateListener.LOSE); this.OnStateChanged(OnStateListener.LOSE); } }
From source file:com.sim2dial.dialer.InCallActivity.java
public void displayCustomToast(final String message, final int duration) { mHandler.post(new Runnable() { @Override/* w w w. j a v a 2 s .com*/ public void run() { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.toast, (ViewGroup) findViewById(R.id.toastRoot)); TextView toastText = (TextView) layout.findViewById(R.id.toastMessage); toastText.setText(message); final Toast toast = new Toast(getApplicationContext()); toast.setGravity(Gravity.CENTER, 0, 0); toast.setDuration(duration); toast.setView(layout); toast.show(); } }); }
From source file:hr.abunicic.angular.CameraActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ApplicationContext.getInstance().init(getApplicationContext()); setContentView(R.layout.activity_camera); //Left drawer drawerLayout = (DrawerLayout) findViewById(R.id.camera_activity_drawer_layout); //Binding the RecyclerView recyclerView = (RecyclerView) findViewById(R.id.r_list); recyclerView.setHasFixedSize(true);/*from ww w . j a v a 2 s. c o m*/ //Informative text when database is empty infoNothingSaved = (TextView) findViewById(R.id.infoNothing); //Getting all saved shaped from the database and populating the RecyclerView db = new DatabaseHandler(CameraActivity.this); historyItems = (ArrayList) db.getAllShapes(); setHistoryItems(); //Card at the bottom cardBottom = (CardView) findViewById(R.id.cardBottom); cardBottom.bringToFront(); //Elements inside the CardView tvShape = (TextView) findViewById(R.id.tvGeomLik); tvCardTitle = (TextView) findViewById(R.id.titleText); tvShape.setMovementMethod(new ScrollingMovementMethod()); final ImageButton imgSave = (ImageButton) findViewById(R.id.imgSave); //Getting instance of the sensor service mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); mGyroSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR); //Initializing the camera and setting up screen size initCamera(); DisplayMetrics displayMetrics = new DisplayMetrics(); this.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); screenHeight = displayMetrics.heightPixels; screenWidth = displayMetrics.widthPixels; //Flash button final ImageButton imgFlash = (ImageButton) findViewById(R.id.imgFlash); if (this.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)) { imgFlash.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (params.getFlashMode().equals(Camera.Parameters.FLASH_MODE_TORCH)) { params.setFlashMode(Camera.Parameters.FLASH_MODE_OFF); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { imgFlash.setBackground(getResources().getDrawable(R.drawable.ic_flash_on_white_36dp)); } } else { params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { imgFlash.setBackground(getResources().getDrawable(R.drawable.ic_flash_off_white_36dp)); } } mCamera.setParameters(params); } }); } else { imgFlash.setVisibility(View.GONE); } //Delete all button in the drawer view ImageButton imgDeleteAll = (ImageButton) findViewById(R.id.imgDeleteAll); imgDeleteAll.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { db.deleteAllShapes(); historyItems.clear(); setHistoryItems(); } }); //Menu icon for opening the drawer ImageButton imgMenu = (ImageButton) findViewById(R.id.imgMenu); imgMenu.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { drawerLayout.openDrawer(Gravity.LEFT); } }); //Fab button functionality fabCapture = (FloatingActionButton) findViewById(R.id.fab); fabCapture.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startDetection(); fabCapture.setClickable(false); FabTransformation.with(fabCapture).transformTo(cardBottom); imgSave.setVisibility(View.VISIBLE); imgSave.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Animation animation = AnimationUtils.loadAnimation(CameraActivity.this, R.anim.anim); mCameraView.startAnimation(animation); Toast toast = Toast.makeText(getApplicationContext(), getResources().getString(R.string.toast_saved), Toast.LENGTH_LONG); //Dodati u strings i u engl verziju toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 0); toast.show(); ShapeInDatabase shapeToAdd = new ShapeInDatabase(mCameraView.getBitmap(), tvCardTitle.getText().toString(), tvShape.getText().toString()); db.addShape(shapeToAdd); historyItems.add(0, shapeToAdd); setHistoryItems(); } }); if (rp != null) { Shape shape = ShapeHeuristic.getShape(rp); if (shape != null) { tvCardTitle.setText(shape.getName()); tvShape.setText(shape.toString()); if (shape instanceof DefaultPolygon && ((DefaultPolygon) shape).getN() == 5) { tvCardTitle.setText("Pravilni peterokut"); tvShape.setText( "Sve stranice pravilnog peterokuta su jednake duljine. \n a = 5 cm \n P = 43.01 \n O = 25"); } } } } }); //Button inside the card for going back Button buttonBack = (Button) findViewById(R.id.buttonBack); buttonBack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { startDetection(); FabTransformation.with(fabCapture).transformFrom(cardBottom); fabCapture.setClickable(true); imgSave.setVisibility(View.INVISIBLE); } }); //Button inside the card for opening the ResultActivity with more info about the shape Button buttonMore = (Button) findViewById(R.id.buttonMore); buttonMore.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Shape shape = ShapeHeuristic.getShape(rp); if (shape instanceof DefaultPolygon && ((DefaultPolygon) shape).getN() == 5) { Intent intentPeterokut = new Intent(CameraActivity.this, PeterokutActivity.class); startActivity(intentPeterokut); } else { Intent intent = new Intent(CameraActivity.this, ResultActivity.class); intent.putExtra("RESULT_TITLE", tvCardTitle.getText().toString()); intent.putExtra("RESULT_INFO", tvShape.getText().toString()); ByteArrayOutputStream bos = new ByteArrayOutputStream(); mCameraView.getBitmap().compress(Bitmap.CompressFormat.PNG, 100, bos); byte[] byteArray = bos.toByteArray(); intent.putExtra("RESULT_IMAGE", byteArray); startActivity(intent); } } }); //Corners View DisplayMetrics displaymetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); cornersView = (CornersView) findViewById(R.id.cornersView); shadow = (FrameLayout) findViewById(R.id.shadowLayout); cornersView.setShadow(shadow); //Starting the detection process startDetection(); //Microblink OCR try { mRecognizer = Recognizer.getSingletonInstance(); } catch (FeatureNotSupportedException e) { Toast.makeText(CameraActivity.this, "Feature not supported! Reason: " + e.getReason().getDescription(), Toast.LENGTH_LONG).show(); finish(); return; } try { // set license key mRecognizer.setLicenseKey(CameraActivity.this, "Y5352CQ5-A7KVPD26-UOAUEX4P-D2GQM63S-J6TCRGNH-T5WFKI24-QQZJRAXL-AT55KX4N"); } catch (InvalidLicenceKeyException exc) { finish(); return; } RecognitionSettings settings = new RecognitionSettings(); // setupSettingsArray method is described in chapter "Recognition settings and results") settings.setRecognizerSettingsArray(setupSettingsArray()); mRecognizer.initialize(CameraActivity.this, settings, new DirectApiErrorListener() { @Override public void onRecognizerError(Throwable t) { Toast.makeText(CameraActivity.this, "There was an error in initialization of Recognizer: " + t.getMessage(), Toast.LENGTH_SHORT) .show(); finish(); } }); }
From source file:org.nla.tarotdroid.lib.ui.GameSetHistoryActivity.java
/** * Starts the whole Facebook post process. * /*ww w.j av a 2 s.c om*/ * @param session */ private void launchPostProcess(final Session session) { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.toast, (ViewGroup) findViewById(R.id.toast_layout_root)); ImageView image = (ImageView) layout.findViewById(R.id.image); image.setImageResource(R.drawable.icon_facebook_released); TextView text = (TextView) layout.findViewById(R.id.text); text.setText("Publication en cours"); Toast toast = new Toast(getApplicationContext()); toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.setView(layout); toast.show(); Request request = Request.newMeRequest(session, new Request.GraphUserCallback() { @Override public void onCompleted(GraphUser user, Response response) { if (session == Session.getActiveSession()) { if (user != null) { int notificationId = FacebookHelper .showNotificationStartProgress(GameSetHistoryActivity.this); AppContext.getApplication().getNotificationIds().put(tempGameSet.getUuid(), notificationId); AppContext.getApplication().setLoggedFacebookUser(user); UpSyncGameSetTask task = new UpSyncGameSetTask(GameSetHistoryActivity.this, progressDialog); task.setCallback(GameSetHistoryActivity.this.upSyncCallback); task.execute(tempGameSet); currentRunningTask = task; } } if (response.getError() != null) { // //progressDialog.dismiss(); // Session newSession = new // Session(GameSetHistoryActivity.this); // Session.setActiveSession(newSession); // newSession.openForPublish(new // Session.OpenRequest(GameSetHistoryActivity.this).setPermissions(Arrays.asList("publish_actions", // "email")).setCallback(facebookSessionStatusCallback)); } } }); request.executeAsync(); }
From source file:com.example.multi_ndef.Frag_Write.java
public boolean varifyTag() { boolean test = false; byte[] NdefSelectAppliFrame = new byte[] { (byte) 0x00, (byte) 0xA4, (byte) 0x04, (byte) 0x00, (byte) 0x07, (byte) 0xD2, (byte) 0x76, (byte) 0x00, (byte) 0x00, (byte) 0x85, (byte) 0x01, (byte) 0x01 }; byte[] CCSelect = new byte[] { (byte) 0x00, (byte) 0xA4, (byte) 0x00, (byte) 0x0C, (byte) 0x02, (byte) 0xE1, (byte) 0x03 }; byte[] CCReadLength = new byte[] { (byte) 0x00, (byte) 0xB0, (byte) 0x00, (byte) 0x00, (byte) 0x0F }; byte[] ndefSelectcmd = new byte[] { (byte) 0x00, (byte) 0xA4, (byte) 0x00, (byte) 0x0C, (byte) 0x02, (byte) 0x00, (byte) 0x01 // Ndef File ID to select };// w ww . j a v a 2 s . c o m // int a = 491; byte[] ndefreadlengthcmd = new byte[] { (byte) 0x00, (byte) 0xB0, (byte) 0x00, (byte) 0x00, (byte) 0x6E }; byte[] readBinary = new byte[] { (byte) 0x00, (byte) 0xB0, (byte) 0x00, (byte) 0x00, (byte) 0x0F }; byte[] SYSSelect = new byte[] { (byte) 0x00, (byte) 0xA4, (byte) 0x00, (byte) 0x0C, (byte) 0x02, (byte) 0xE1, (byte) 0x01 }; byte[] response1 = new byte[] { (byte) 0x01, (byte) 0x00, (byte) 0x00 }; byte[] response2 = new byte[] { (byte) 0x01, (byte) 0x00, (byte) 0x00 }; byte[] response3 = new byte[] { (byte) 0x01, (byte) 0x00, (byte) 0x00 }; byte[] response4 = new byte[] { (byte) 0x01, (byte) 0x00, (byte) 0x00 }; byte[] response5 = new byte[] { (byte) 0x01, (byte) 0x00, (byte) 0x00 }; byte[] response6 = new byte[] { (byte) 0x01, (byte) 0x00, (byte) 0x00 }; byte[] response7 = new byte[] { (byte) 0x01, (byte) 0x00, (byte) 0x00 }; byte[] response8 = new byte[] { (byte) 0x01, (byte) 0x00, (byte) 0x00 }; try { IsoDep isoDepCurrentTag = (IsoDep) IsoDep.get(ma.getCurrentTag()); NfcA nfcaTag = (NfcA) NfcA.get(ma.getCurrentTag()); nfcaTag.close(); boolean a; a = isoDepCurrentTag.isConnected(); byte[] at = new byte[10]; //at=isoDepCurrentTag.getAtqa(); isoDepCurrentTag.connect(); int time; time = isoDepCurrentTag.getTimeout(); response1 = isoDepCurrentTag.transceive(NdefSelectAppliFrame); response2 = isoDepCurrentTag.transceive(CCSelect); response3 = isoDepCurrentTag.transceive(CCReadLength); response4 = isoDepCurrentTag.transceive(SYSSelect); response5 = isoDepCurrentTag.transceive(readBinary); int ad = 10; isoDepCurrentTag.close(); } catch (Exception e) { String exp = e.toString(); Toast toast = Toast.makeText(getApplicationContext(), "Tag not found in range. Press back button and re click Write button", Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER | Gravity.CENTER, 0, 0); toast.show(); } if (response5[8] == (byte) 0x02) { test = true; } else { test = false; } return test; }
From source file:com.example.carsharing.CommuteActivity.java
public void DisplayToast(String str) { Toast toast = Toast.makeText(this, str, Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM, 0, 50); toast.show();//from ww w. j a v a 2 s. c o m }
From source file:com.example.multi_ndef.Frag_Write.java
/** * Called when our blank tag is scanned executing the PendingIntent */// w w w. jav a2 s . com //@SuppressLint("InlinedApi") @Override public void onNewIntent(Intent intent) { try { if (mInWriteMode) { mInWriteMode = false; // write to newly scanned tag Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); Tag tagFromIntent = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); ma.setCurrentTag(tagFromIntent); boolean cardCheck = false; cardCheck = varifyTag(); if (cardCheck) { writeTag(tag); } else if (!cardCheck) { Toast toast = Toast.makeText(getApplicationContext(), "Verification failed. Please use STMicroelectronics SR Tag to continue.", Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER | Gravity.CENTER, 0, 0); toast.show(); } } } catch (Exception e) { } }