@Override
  public void onReceive(final Context context, Intent intent) {

    ApiHandler.Initialize(context);
    final DataAccessObject dao = new DataAccessObject(context);

    if (intent.hasExtra("newMessage")) {

      String messageId = intent.getStringExtra("newMessage");
      try {
        ApiHandler.RetrieveMessage(
            Long.parseLong(messageId),
            new Callback<Message>() {
              @Override
              public void Invoke(Message result) {
                dao.WriteMessageToUserConversation(result, false);
                NotificationHandler.SendNotification(
                    result.getFrom(), result.getContnet(), context);
              }
            });
      } catch (NumberFormatException e) {
        Log.e(getClass().toString(), "Could not parse messageId as long: " + e.getMessage());
      }

    } else if (intent.hasExtra("message")) {
      try {
        String m = intent.getStringExtra("message");
        JSONObject json = new JSONObject(m);
        GcmMessageHandler.HandleMessage(context, json, m);
      } catch (JSONException e) {
        Log.e(getClass().toString(), e.getMessage());
      }
    }
  }
    @Override
    public void onReceive(Context context, Intent intent) {
      /*
       * Close the notification bar in order to see the toast that module
       * was enabled successfully. Furthermore, if SU permissions haven't
       * been granted yet, the SU dialog will be prompted behind the
       * expanded notification panel and is therefore not visible to the
       * user.
       */
      sContext.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
      cancelAll();

      if (intent.hasExtra(EXTRA_ACTIVATE_MODULE)) {
        String packageName = intent.getStringExtra(EXTRA_ACTIVATE_MODULE);
        ModuleUtil moduleUtil = ModuleUtil.getInstance();
        moduleUtil.setModuleEnabled(packageName, true);
        moduleUtil.updateModulesList(false);
        Toast.makeText(sContext, R.string.module_activated, Toast.LENGTH_SHORT).show();

        if (intent.hasExtra(EXTRA_ACTIVATE_MODULE_AND_RETURN)) return;
      }

      RootUtil rootUtil = new RootUtil();
      if (!rootUtil.startShell()) {
        Log.e(XposedApp.TAG, "Could not start root shell");
        return;
      }

      boolean isSoftReboot = intent.getBooleanExtra(EXTRA_SOFT_REBOOT, false);
      rootUtil.reboot(
          isSoftReboot ? RootUtil.RebootMode.SOFT : RootUtil.RebootMode.NORMAL,
          new RootUtil.LogLineCallback());

      AssetUtil.removeBusybox();
    }
示例#3
1
  private void encodeFromTextExtras(Intent intent) throws WriterException {
    // Notice: Google Maps shares both URL and details in one text, bummer!
    String theContents = ContactEncoder.trim(intent.getStringExtra(Intent.EXTRA_TEXT));
    if (theContents == null) {
      theContents = ContactEncoder.trim(intent.getStringExtra("android.intent.extra.HTML_TEXT"));
      // Intent.EXTRA_HTML_TEXT
      if (theContents == null) {
        theContents = ContactEncoder.trim(intent.getStringExtra(Intent.EXTRA_SUBJECT));
        if (theContents == null) {
          String[] emails = intent.getStringArrayExtra(Intent.EXTRA_EMAIL);
          if (emails != null) {
            theContents = ContactEncoder.trim(emails[0]);
          } else {
            theContents = "?";
          }
        }
      }
    }

    // Trim text to avoid URL breaking.
    if (theContents == null || theContents.isEmpty()) {
      throw new WriterException("Empty EXTRA_TEXT");
    }
    contents = theContents;
    // We only do QR code.
    format = BarcodeFormat.QR_CODE;
    if (intent.hasExtra(Intent.EXTRA_SUBJECT)) {
      displayContents = intent.getStringExtra(Intent.EXTRA_SUBJECT);
    } else if (intent.hasExtra(Intent.EXTRA_TITLE)) {
      displayContents = intent.getStringExtra(Intent.EXTRA_TITLE);
    } else {
      displayContents = contents;
    }
    title = activity.getString(R.string.contents_text);
  }
 @Override
 public void onReceive(Context context, Intent intent) {
   // TODO Auto-generated method stub
   if (intent.getAction().equals("android.intent.action.HEADSET_PLUG")) {
     headset_name.setText("headset name = " + intent.getStringExtra("name"));
     if (intent.hasExtra("state")) {
       if (0 == intent.getIntExtra("state", 2)) {
         // 耳机拔出
         headset_name.setText("");
         headset_img.setImageResource(R.drawable.phoneflat);
       }
       if (1 == intent.getIntExtra("state", 2)) {
         // 耳机插入
         if (intent.hasExtra("microphone")) {
           if (0 == intent.getIntExtra("microphone", 2)) {
             // 耳机没有麦克风
             headset_img.setImageResource(R.drawable.headset_without_mic);
           }
           if (1 == intent.getIntExtra("microphone", 2)) {
             // 耳机有麦克风
             headset_img.setImageResource(R.drawable.headset_with_mic);
           }
         }
       }
     }
   }
 }
示例#5
1
 @Test
 public void testHasExtra() throws Exception {
   Intent intent = new Intent();
   assertSame(intent, intent.putExtra("foo", ""));
   assertTrue(intent.hasExtra("foo"));
   assertFalse(intent.hasExtra("bar"));
 }
示例#6
1
  // 인텐트 받아왔을 때.. 근데 이거 있으면 onStart 호출 불가
  protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    setIntent(intent);

    //        if (intent.hasExtra("bm")) {
    //            Log.d("MainActivity : ", "bm is not null");
    //
    //            bm = intent.getParcelableExtra("bm");
    //            adapterViewPager.setImageView(bm);
    //
    //        } else {
    //            Log.d("MainActivity : ", "bm is null");
    //        }

    if (intent.hasExtra("card")) {
      adapterViewPager.setCardItem((Card) intent.getParcelableExtra("card"));
    }

    if (intent.hasExtra("keyword")) {
      keyword = intent.getStringArrayListExtra("keyword");
      Log.d("In mainActivity : ", keyword.get(0));
      Log.d("In mainActivity : ", keyword.get(1));
      Log.d("In mainActivity : ", keyword.get(2));
      Log.d("In mainActivity : ", keyword.get(3));
      Log.d("In mainActivity : ", keyword.get(4));

      //            FirstFragment fragment = new FirstFragment();
      //            Bundle bundle = new Bundle();
      //            bundle.putStringArrayList("keyword", keyword);
      //            fragment.setArguments(bundle);

      adapterViewPager.getFirstFragment().getkeyword(keyword);
    }
  }
示例#7
0
 @Override
 public void onReceive(Context context, Intent intent) {
   String action = intent.getAction();
   if (action.equals(JaneIntent)) {
     Log.d("Jane", "Intent from JaneIntent: " + intent);
     bluetoothConnected = false;
     if (intent != null) {
       if (intent.hasExtra("utterance_completed")) {
         utteranceCompletedThreadsafe();
       } else if (intent.hasExtra("start_listening")) {
         listen();
       } else if (intent.hasExtra("shutdown")) {
         stopSelf();
       }
     }
   } else if (action.equals(Honeycomb.BLUETOOTH_STATE)) {
     Log.d("Jane", "Intent from BluetoothState: " + intent);
     if (intent.hasExtra("bluetooth_connected")) {
       bluetoothConnected = intent.getExtras().getBoolean("bluetooth_connected");
       if (bluetoothConnected) {
         listen();
       }
     }
   }
 }
示例#8
0
  public int onStartCommand(Intent intent, int flags, int startId) {
    Log.i("unidevel.UnlockService", "onStartCommand");
    if (intent != null && intent.hasExtra("lock") && intent.hasExtra("unlock")) {
      boolean lock = intent.getBooleanExtra("lock", false);
      boolean unlock = intent.getBooleanExtra("unlock", true);
      SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
      if (pref != null) {
        SharedPreferences.Editor edit = pref.edit();
        edit.putBoolean("aunlocker.lock", lock);
        edit.putBoolean("aunlocker.unlock", unlock);
        edit.commit();
      }
    }
    if (this.receiver == null) {
      Log.i("unidevel.UnlockService", "onStartCommand.registerReceiver");
      this.receiver = new ScreenReceiver();
      this.receiver.setService(this);
      IntentFilter it = new IntentFilter();
      it.addAction(Intent.ACTION_SCREEN_OFF);
      it.addAction(Intent.ACTION_SCREEN_ON);
      registerReceiver(this.receiver, it);

      PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
      if (!pm.isScreenOn()) {
        Log.i("unidevel.UnlockService", "onStartCommand init with screen off");
        onScreenOff();
      } else {
        Log.i("unidevel.UnlockService", "onStartCommand init with screen on");
        onScreenOn();
      }
    }
    return Service.START_STICKY;
  }
 @Override
 protected void onResume() {
   super.onResume();
   selectAddress = getIntent() != null && getIntent().getBooleanExtra(SELECT_ADDRESS, false);
   setOnItemClickListener(
       new AdapterView.OnItemClickListener() {
         @Override
         public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
           T repo = getListAdapter().getItem(position);
           itemSelectedBase(repo, view);
         }
       });
   Intent intent = getIntent();
   if (intent != null) {
     if (intent.hasExtra(SearchActivity.SEARCH_LAT)
         && intent.hasExtra(SearchActivity.SEARCH_LON)) {
       double lat = intent.getDoubleExtra(SearchActivity.SEARCH_LAT, 0);
       double lon = intent.getDoubleExtra(SearchActivity.SEARCH_LON, 0);
       locationToSearch = new LatLon(lat, lon);
     }
   }
   if (locationToSearch == null) {
     locationToSearch = settings.getLastKnownMapLocation();
   }
 }
示例#10
0
  /**
   * Entry point to add a new operation to the queue of operations.
   *
   * <p>New operations are added calling to startService(), resulting in a call to this method. This
   * ensures the service will keep on working although the caller activity goes away.
   */
  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {
    Log_OC.d(TAG, "Starting command with id " + startId);

    // WIP: for the moment, only SYNC_FOLDER is expected here;
    // the rest of the operations are requested through the Binder
    if (ACTION_SYNC_FOLDER.equals(intent.getAction())) {

      if (!intent.hasExtra(EXTRA_ACCOUNT) || !intent.hasExtra(EXTRA_REMOTE_PATH)) {
        Log_OC.e(TAG, "Not enough information provided in intent");
        return START_NOT_STICKY;
      }
      Account account = intent.getParcelableExtra(EXTRA_ACCOUNT);
      String remotePath = intent.getStringExtra(EXTRA_REMOTE_PATH);

      Pair<Account, String> itemSyncKey = new Pair<Account, String>(account, remotePath);

      Pair<Target, RemoteOperation> itemToQueue = newOperation(intent);
      if (itemToQueue != null) {
        mSyncFolderHandler.add(
            account, remotePath, (SynchronizeFolderOperation) itemToQueue.second);
        Message msg = mSyncFolderHandler.obtainMessage();
        msg.arg1 = startId;
        msg.obj = itemSyncKey;
        mSyncFolderHandler.sendMessage(msg);
      }

    } else {
      Message msg = mOperationsHandler.obtainMessage();
      msg.arg1 = startId;
      mOperationsHandler.sendMessage(msg);
    }

    return START_NOT_STICKY;
  }
示例#11
0
  /** center the map on the markers */
  public void centerMapFile() {
    MarkerOverlay mo = mapView.getMarkerOverlay();
    MapPosition mp = mapView.getMapViewPosition().getMapPosition();

    Intent intent = getIntent();
    if (intent.hasExtra(PARAMETERS.LAT)
        && intent.hasExtra(PARAMETERS.LON)
        && intent.hasExtra(PARAMETERS.ZOOM_LEVEL)) {
      double lat = intent.getDoubleExtra(PARAMETERS.LAT, 43.68411);
      double lon = intent.getDoubleExtra(PARAMETERS.LON, 10.84899);
      byte zoom_level = intent.getByteExtra(PARAMETERS.ZOOM_LEVEL, (byte) 13);
      byte zoom_level_min = intent.getByteExtra(PARAMETERS.ZOOM_LEVEL_MIN, (byte) 0);
      byte zoom_level_max = intent.getByteExtra(PARAMETERS.ZOOM_LEVEL_MAX, (byte) 30);
      /*ArrayList<MarkerDTO> list_marker = intent.getParcelableArrayListExtra(PARAMETERS.MARKERS);
      MarkerDTO mark = list_marker.get(0);*/
      mp = new MapPosition(new GeoPoint(lat, lon), zoom_level);
      mapView.getMapViewPosition().setMapPosition(mp);
      mapView.getMapZoomControls().setZoomLevelMin(zoom_level_min);
      mapView.getMapZoomControls().setZoomLevelMax(zoom_level_max);
    } else {
      if (mo != null) {
        // support only one marker
        MapPosition newMp = MarkerUtils.getMarkerCenterZoom(mo.getMarkers(), mp);
        if (newMp != null) {
          mapView.getMapViewPosition().setMapPosition(newMp);
        }
      }
    }
  }
示例#12
0
  @Override
  protected void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.activity_imageview);

    final ImageView imageView = (ImageView) findViewById(R.id.image_view);
    Intent intent = getIntent();
    if (intent.hasExtra(IMAGE_URI)) {
      Uri uri = Uri.parse(intent.getExtras().getString(IMAGE_URI));
      Picasso.with(this).load(uri).fit().centerInside().into(imageView);
    } else if (intent.hasExtra(TYPE_KEY)) {
      String type = intent.getExtras().getString(TYPE_KEY);
      try {
        String json = getSharedPreferences(type, Context.MODE_PRIVATE).getString(type, null);
        String base64 = (new JSONObject(json)).getString(IMAGE_KEY);
        imageView.setImageBitmap(FileUtils.base64ToBitmap(base64));
      } catch (JSONException e) {
        e.printStackTrace();
      }
    }
  }
示例#13
0
        @Override
        public void onReceive(Context context, Intent intent) {
          if (intent.hasExtra(getString(R.string.intent_bl_stopped))) {
            invalidateOptionsMenu();
          } else if (intent.hasExtra(getString(R.string.intent_action_bl_user_stopped))) {
            invalidateOptionsMenu();
          } else if (intent.hasExtra(getString(R.string.intent_action_bl_user_changing))) {

          }
        }
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (resultCode != RESULT_OK) {
     return;
   }
   switch (requestCode) {
     case REQUEST_CODE_SHOW_PRODUCT:
       Trace.e(TAG, "Show Product:result data->" + (null == data ? "null" : data.toString()));
       if (data != null
           && data.hasExtra(ProductDetailActivity.KEY_PRODUCT_REC)
           && data.hasExtra(ProductDetailActivity.KEY_POST_NUMBER)
           && data.hasExtra(ProductDetailActivity.KEY_EDIT_TYPE)) {
         ProductRec productRec =
             (ProductRec) data.getSerializableExtra(ProductDetailActivity.KEY_PRODUCT_REC);
         int pos = (Integer) data.getSerializableExtra(ProductDetailActivity.KEY_POST_NUMBER);
         int editType =
             data.getIntExtra(
                 ProductDetailActivity.KEY_EDIT_TYPE, ProductDetailActivity.TYPE_EDIT_PRODUCT);
         // 移除记录满足以下条件即可:
         // (1)藏品做了移除操作;
         // (2)藏品做了下架操作;
         // (3)藏品做了重新设置了分类操作;
         boolean isNeedRemoveProduct = false;
         if (editType == ProductDetailActivity.TYPE_REMOVE_PRODUCT) {
           isNeedRemoveProduct = true;
         } else {
           //					if(null != productRec){
           ////						isNeedRemoveProduct = !productRec.isOnSale();
           ////						String catId = productRec.getCatId();
           //						String currPageCatId = null == tagRec ? null : tagRec.getId();
           //						if(!isNeedRemoveProduct && null != catId && null != currPageCatId &&
           // !catId.equalsIgnoreCase(currPageCatId)){
           //							isNeedRemoveProduct = true;
           //						}
           //					}
         }
         if (isNeedRemoveProduct) {
           try {
             productList.remove(pos);
           } catch (Exception e) {
             Log.e(TAG, "Remove ProductRec failure: pos outOfArrIndex Exception.", e);
           }
         } else {
           //					productList.get(pos).setInFav(productRec.getInFav());
           //					productList.get(pos).setFavNum(productRec.getFavNum());
         }
         productAdapter.notifyDataSetInvalidated();
       }
       break;
     case FOR_LOGIN_RESULT:
       readyToGetAllGoodsByTagID(tagRec.getId(), true);
       break;
     default:
       break;
   }
 };
示例#15
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.add_bookmark);

    Intent intent = getIntent();

    if (Intent.ACTION_SEND.equals(intent.getAction()) && intent.hasExtra(Intent.EXTRA_TEXT)) {
      bookmark = new Bookmark();

      ShareCompat.IntentReader reader = ShareCompat.IntentReader.from(this);

      String url = StringUtils.getUrl(reader.getText().toString());
      bookmark.setUrl(url);

      if (reader.getSubject() != null) bookmark.setDescription(reader.getSubject());

      if (url.equals("")) {
        Toast.makeText(this, R.string.add_bookmark_invalid_url, Toast.LENGTH_LONG).show();
      }

      if (intent.hasExtra(Constants.EXTRA_DESCRIPTION)) {
        bookmark.setDescription(intent.getStringExtra(Constants.EXTRA_DESCRIPTION));
      }
      bookmark.setNotes(intent.getStringExtra(Constants.EXTRA_NOTES));
      bookmark.setTagString(intent.getStringExtra(Constants.EXTRA_TAGS));
      bookmark.setShared(!intent.getBooleanExtra(Constants.EXTRA_PRIVATE, privateDefault));

      try {
        Bookmark old = BookmarkManager.GetByUrl(bookmark.getUrl(), this);
        bookmark = old.copy();
      } catch (Exception e) {

      }

    } else if (Intent.ACTION_EDIT.equals(intent.getAction())) {
      int id = Integer.parseInt(intent.getData().getLastPathSegment());
      try {
        bookmark = BookmarkManager.GetById(id, this);
        oldBookmark = bookmark.copy();

        update = true;
      } catch (ContentNotFoundException e) {
        e.printStackTrace();
      }
    }

    if (update) setTitle(getString(R.string.add_bookmark_edit_title));
    else setTitle(getString(R.string.add_bookmark_add_title));

    frag =
        (AddBookmarkFragment)
            getSupportFragmentManager().findFragmentById(R.id.add_bookmark_fragment);
    frag.loadBookmark(bookmark, oldBookmark);
  }
 private VibratePattern getVibratePatternFromIntent(Intent intent) {
   /* Set up vibrate pattern. */
   VibratePattern vibrate = Notification.VibratePattern.NO_VIBRATE;
   if (intent.hasExtra("vibrate_on")
       && intent.hasExtra("vibrate_off")
       && intent.hasExtra("vibrate_cycles")) {
     int vibrateOn = intent.getIntExtra("vibrate_on", 500);
     int vibrateOff = intent.getIntExtra("vibrate_off", 500);
     int vibrateCycles = intent.getIntExtra("vibrate_cycles", 3);
     vibrate = new VibratePattern(true, vibrateOn, vibrateOff, vibrateCycles);
   }
   return vibrate;
 }
  private void handleNoteData() {
    noteProvider = NoteProvider.get(getApplicationContext());

    Intent intent = getIntent();
    if (intent.hasExtra(EXTRA_CREATE_NEW_NOTE)) {
      note = new Note();
      noteExistsInDatabase = false;

      showKeyboardOnTitleEditText();
    } else if (intent.hasExtra(EXTRA_NOTE_ID)) {
      setUpNoteFromDatabase(intent);
    }
  }
  private void initialize(Bundle savedInstanceState) {
    Intent intent = getIntent();
    String roomName = null;
    String creator = null;
    if (intent.hasExtra(ChatRoomName.CHATROOM_NAME)) {
      modeType = MODE_CHATROOM_INITIATED_INTERCOM;
      Bundle extras = intent.getExtras();
      if (extras != null) {
        roomName = extras.getString(ChatRoomName.CHATROOM_NAME);
        if (TextUtils.isEmpty(roomName)) {
          finish();
        } else {
          creator = extras.getString(ChatRoomName.CHATROOM_CREATOR);
          if (CCPConfig.VoIP_ID.equals(creator)) {
            handleTitleDisplay(
                getString(R.string.btn_title_back),
                roomName,
                getString(R.string.app_title_right_button_pull_down));
          } else {
            handleTitleDisplay(getString(R.string.btn_title_back), roomName, null);
          }
        }
      }
    }

    if (intent.hasExtra(Device.CONFNO)) {
      // To invite voice group chat
      modeType = MODE_CHATROOM_INVITATION;
      Bundle extras = intent.getExtras();
      if (extras != null) {
        mCurrentRoomNum = extras.getString(Device.CONFNO);
        if (TextUtils.isEmpty(mCurrentRoomNum)) {
          finish();
        }
      }
    }
    mNoticeTips.setText(R.string.top_tips_connecting_wait);

    // Launched a group chat room request, waiting for SDK to return.
    if (modeType == MODE_CHATROOM_INITIATED_INTERCOM) {
      VoiceHelper.getInstance()
          .getDevice()
          .startChatroom(CCPConfig.App_ID, roomName, 8, null, null);
    } else if (modeType == MODE_CHATROOM_INVITATION) {

      // Initiate a join group chat room request, waiting for SDK to return.
      VoiceHelper.getInstance().getDevice().joinChatroom(mCurrentRoomNum);
    }
  }
  /**
   * Create a {@link FabTransform} from the supplied {@code activity} extras and set as its shared
   * element enter/return transition.
   */
  public static boolean setup(@NonNull Activity activity, @Nullable View target) {
    final Intent intent = activity.getIntent();
    if (!intent.hasExtra(EXTRA_FAB_COLOR) || !intent.hasExtra(EXTRA_FAB_ICON_RES_ID)) {
      return false;
    }

    final int color = intent.getIntExtra(EXTRA_FAB_COLOR, Color.TRANSPARENT);
    final int icon = intent.getIntExtra(EXTRA_FAB_ICON_RES_ID, -1);
    final FabTransform sharedEnter = new FabTransform(color, icon);
    if (target != null) {
      sharedEnter.addTarget(target);
    }
    activity.getWindow().setSharedElementEnterTransition(sharedEnter);
    return true;
  }
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (requestCode == ACTION_EDIT_DOCUMENT && resultCode == RESULT_OK) {
     if (data.hasExtra(BaseDocumentLayoutActivity.DOCUMENT)) {
       Document editedDocument =
           (Document) data.getExtras().get(BaseDocumentLayoutActivity.DOCUMENT);
       onDocumentUpdate(editedDocument);
     }
   } else if (requestCode == ACTION_CREATE_DOCUMENT && resultCode == RESULT_OK) {
     if (data.hasExtra(BaseDocumentLayoutActivity.DOCUMENT)) {
       Document newDocument = (Document) data.getExtras().get(BaseDocumentLayoutActivity.DOCUMENT);
       onDocumentCreate(newDocument);
     }
   }
 }
示例#21
0
 @Override
 protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
   if (resultCode == RESULT_OK) {
     if (requestCode == REQUEST_GALLERY) {
       if (data.getData() != null) {
         execute(messenger().sendUri(peer, data.getData()), R.string.pick_downloading);
       }
     } else if (requestCode == REQUEST_PHOTO) {
       messenger().sendPhoto(peer, pending_fileName);
     } else if (requestCode == REQUEST_VIDEO) {
       messenger().sendVideo(peer, pending_fileName);
     } else if (requestCode == REQUEST_DOC) {
       if (data.getData() != null) {
         execute(messenger().sendUri(peer, data.getData()), R.string.pick_downloading);
       } else if (data.hasExtra("picked")) {
         ArrayList<String> files = data.getStringArrayListExtra("picked");
         if (files != null) {
           for (String s : files) {
             messenger().sendDocument(peer, s);
           }
         }
       }
     }
   }
 }
  @Override
  public void onReceive(Context context, Intent intent) {
    /** Place to start service,activity or notification or any other action */
    System.out.println(TAG + " @OnReceive :" + intent.getAction());
    if (intent.hasExtra(Extras.URL)) {
      String url = intent.getStringExtra(Extras.URL);
      Intent intent1 = new Intent(context, BroadCastActivity.class);
      intent1.setAction(Intent.ACTION_MAIN);
      intent1.setAction(Intent.CATEGORY_LAUNCHER);
      intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      PendingIntent pendingIntent =
          PendingIntent.getActivity(context, 1, intent1, PendingIntent.FLAG_UPDATE_CURRENT);

      Notification notification =
          new NotificationCompat.Builder(context)
              .setContentTitle("Downloaded json")
              .setContentText(url)
              .setContentIntent(pendingIntent)
              .setSmallIcon(R.drawable.ic_stat_av_play_circle_outline)
              .setWhen(System.currentTimeMillis())
              .build();
      NotificationManager notificationManager =
          (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
      notificationManager.notify((int) (Math.random() * 100), notification);
    }
  }
  @Override
  protected void onResume() {
    super.onResume();

    searchPoint = osmandSettings.getLastSearchedPoint();

    Intent intent = getIntent();
    if (intent != null) {
      selectAddressMode = intent.hasExtra(SELECT_ADDRESS_POINT_INTENT_KEY);
    } else {
      selectAddressMode = false;
    }
    findViewById(R.id.TopTextView).setVisibility(selectAddressMode ? View.VISIBLE : View.GONE);

    region = null;
    postcode = null;
    city = null;
    street = null;
    building = null;
    region = osmandSettings.getLastSearchedRegion();
    RegionAddressRepository reg =
        ((OsmandApplication) getApplication()).getResourceManager().getRegionRepository(region);
    if (reg != null && reg.useEnglishNames() != osmandSettings.USE_ENGLISH_NAMES.get()) {
      reg.setUseEnglishNames(osmandSettings.USE_ENGLISH_NAMES.get());
    }
    loadData();
    updateUI();
  }
示例#24
0
    @Override
    protected void onPostExecute(Intent intent) {
      mAuthTask = null;
      showProgress(false);

      if (intent.hasExtra(KEY_ERROR_MESSAGE)) {
        String error = intent.getStringExtra(KEY_ERROR_MESSAGE);
        if (GtgOnlineServerAuthenticate.INVALID_PASSWORD.equals(error)) {
          mPasswordView.setError(getResources().getString(R.string.error_incorrect_password));
          mPasswordView.requestFocus();
        } else if (GtgOnlineServerAuthenticate.NET_ERROR.equals(error)) {
          Toast.makeText(
                  getBaseContext(),
                  getResources().getString(R.string.network_error),
                  Toast.LENGTH_SHORT)
              .show();
        } else {
          Toast.makeText(
                  getBaseContext(),
                  getResources().getString(R.string.unknown_error),
                  Toast.LENGTH_SHORT)
              .show();
        }
      } else {
        finishLogin(intent);
      }
    }
示例#25
0
 @Override
 public void onReceive(Context context, Intent intent) {
   setProgressBarIndeterminateVisibility(false);
   if (ACTION_UPLOAD.equals(intent.getAction())
       && intent.hasExtra(UploadService.EXTRA_RESPONSE)) {
     final Uri uri = Uri.parse(intent.getStringExtra(UploadService.EXTRA_RESPONSE));
     mHandler.post(
         new Runnable() {
           @Override
           public void run() {
             AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
             builder
                 .setTitle(R.string.upload_complete)
                 .setMessage(R.string.upload_open_in_browser);
             builder.setPositiveButton(
                 R.string.yes,
                 new DialogInterface.OnClickListener() {
                   @Override
                   public void onClick(DialogInterface dialog, int id) {
                     startActivity(new Intent(Intent.ACTION_VIEW, uri));
                   }
                 });
             builder.setNegativeButton(
                 R.string.no,
                 new DialogInterface.OnClickListener() {
                   public void onClick(DialogInterface dialog, int id) {
                     dialog.cancel();
                   }
                 });
             builder.show();
           }
         });
   }
 }
示例#26
0
        @SuppressWarnings("nls")
        @Override
        public void onReceive(Context context, Intent intent) {
          System.err.println("TVA thug hustlin - ");

          if (!intent.hasExtra("tag_id")) return;
          System.err.println(
              Long.toString(tagData.getValue(TagData.REMOTE_ID))
                  + " VS "
                  + intent.getStringExtra("tag_id"));
          if (!Long.toString(tagData.getValue(TagData.REMOTE_ID))
              .equals(intent.getStringExtra("tag_id"))) return;

          runOnUiThread(
              new Runnable() {
                @Override
                public void run() {
                  System.err.println("REFRESH updates list pa-pa-pa");
                  refreshUpdatesList();
                }
              });
          refreshData(false, true);

          NotificationManager nm = new AndroidNotificationManager(ContextManager.getContext());
          nm.cancel(tagData.getValue(TagData.REMOTE_ID).intValue());
        }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
      visibleLeakRefKey = savedInstanceState.getString("visibleLeakRefKey");
    } else {
      Intent intent = getIntent();
      if (intent.hasExtra(SHOW_LEAK_EXTRA)) {
        visibleLeakRefKey = intent.getStringExtra(SHOW_LEAK_EXTRA);
      }
    }

    //noinspection unchecked
    leaks = (List<Leak>) getLastNonConfigurationInstance();

    setContentView(R.layout.leak_canary_display_leak);

    listView = (ListView) findViewById(R.id.__leak_canary_display_leak_list);
    failureView = (TextView) findViewById(R.id.__leak_canary_display_leak_failure);
    actionButton = (Button) findViewById(R.id.__leak_canary_action);

    maxStoredLeaks = getResources().getInteger(R.integer.leak_canary_max_stored_leaks);

    updateUi();
  }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == TAKE_PICTURE) {
      if (data != null) {
        if (data.hasExtra("data")) {
          b = data.getParcelableExtra("data");
        }
      } else {
        b = BitmapFactory.decodeFile(name);
      }
    } else if (requestCode == SELECT_PICTURE) {
      Uri selectedImage = data.getData();
      InputStream is;
      try {
        is = getContentResolver().openInputStream(selectedImage);
        BufferedInputStream bis = new BufferedInputStream(is);
        b = BitmapFactory.decodeStream(bis);

      } catch (FileNotFoundException e) {
        e.printStackTrace();
      }
    }
    try {
      // b = Bitmap.createScaledBitmap(b, 640, 480, true);
      bmini = Bitmap.createScaledBitmap(b, 64, 64, true);
      Toast.makeText(this, "Imagen Almacenada", Toast.LENGTH_SHORT).show();
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
示例#29
0
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    Log.v("search", this.getClass().getName() + " onActivityResult invoked");
    if (resultCode == MainActivity.RESULT_OK && requestCode == MainActivity.RECIPE_REQUEST_CODE) {
      Log.v("search", "onActivity condition");
      if (data.hasExtra(MainActivity.EXTRA_RECIPE)) {

        recipe = (Recipe) data.getSerializableExtra(MainActivity.EXTRA_RECIPE);
        //				for(ProcIngredient i:recipe.getIngredients()){
        //					if(i.isCheck()){
        //						Log.v("search", "true");
        //					}
        //					else{
        //						Log.v("search", "false");
        //					}
        //				}

        for (int i = 0; i < recipes.size(); i++) {
          if (recipe.getRecipeName().equals(recipes.get(i).getRecipeName())) {
            Log.v("search", "yesss");
            recipes.remove(i);
            recipes.add(i, recipe);
            break;
          }
        }
        adapter.notifyDataSetChanged();
      }
    }
    Log.v("search", this.getClass().getName() + " onActivityResult end");
  }
示例#30
0
 private void loadType() {
   Intent getIntent = getIntent();
   if (getIntent.hasExtra("type")) {
     String Type = getIntent.getStringExtra("type");
     value.setType(Type);
   }
 }