@Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
      case REQUEST_CODE_PUBLIC_KEYS:
        {
          if (resultCode == Activity.RESULT_OK) {
            Bundle bundle = data.getExtras();
            setEncryptionKeyIds(
                bundle.getLongArray(SelectPublicKeyActivity.RESULT_EXTRA_MASTER_KEY_IDS));
          }
          break;
        }

      case REQUEST_CODE_SECRET_KEYS:
        {
          if (resultCode == Activity.RESULT_OK) {
            Uri uriMasterKey = data.getData();
            setSignatureKeyId(Long.valueOf(uriMasterKey.getLastPathSegment()));
          } else {
            setSignatureKeyId(Constants.key.none);
          }
          break;
        }

      default:
        {
          super.onActivityResult(requestCode, resultCode, data);

          break;
        }
    }
  }
예제 #2
0
  /**
   * Get the saved contact name related to the number from the phonebook
   *
   * @param number
   * @return
   */
  public String getContactByNbr(String number) {
    String contact = "";

    Uri uri =
        Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
    ContentResolver contentResolver = getContentResolver();
    Cursor cursor =
        contentResolver.query(
            uri,
            new String[] {BaseColumns._ID, ContactsContract.PhoneLookup.DISPLAY_NAME},
            null,
            null,
            null);

    if (cursor != null && cursor.getCount() > 0) {
      try {
        cursor.moveToNext();
        contact = cursor.getString(cursor.getColumnIndex(ContactsContract.Data.DISPLAY_NAME));
      } catch (Exception e) {

      } finally {
        cursor.close();
      }
    }
    if (contact.length() == 0) return number;
    return contact;
  }
예제 #3
0
  @Override
  public void setBinaryData(Object answer) {
    // you are replacing an answer. delete the previous image using the
    // content provider.
    if (mBinaryName != null) {
      deleteMedia();
    }

    File newImage = (File) answer;
    if (newImage.exists()) {
      // Add the new image to the Media content provider so that the
      // viewing is fast in Android 2.0+
      ContentValues values = new ContentValues(6);
      values.put(Images.Media.TITLE, newImage.getName());
      values.put(Images.Media.DISPLAY_NAME, newImage.getName());
      values.put(Images.Media.DATE_TAKEN, System.currentTimeMillis());
      values.put(Images.Media.MIME_TYPE, "image/jpeg");
      values.put(Images.Media.DATA, newImage.getAbsolutePath());

      Uri imageURI =
          getContext().getContentResolver().insert(Images.Media.EXTERNAL_CONTENT_URI, values);
      Log.i(t, "Inserting image returned uri = " + imageURI.toString());

      mBinaryName = newImage.getName();
      Log.i(t, "Setting current answer to " + newImage.getName());
    } else {
      Log.e(t, "NO IMAGE EXISTS at: " + newImage.getAbsolutePath());
    }

    Collect.getInstance().getFormController().setIndexWaitingForData(null);
  }
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
      case FILE_SELECT_CODE:
        if (resultCode == Activity.RESULT_OK) {
          // Get the Uri of the selected file
          Uri uri = data.getData();

          Log.d(LOG_TAG, "File Uri: " + uri.toString());
          try {
            filePath = FileUtils.getPath(getActivity(), uri);
            fileChoosen = new File(filePath);

            if (fileChoosen != null) {
              tv_choose_file.setText(fileChoosen.getName());
            } else {
              break;
            }
            bt_upload.setEnabled(true);

          } catch (URISyntaxException e) {
            Log.d(LOG_TAG, e.getLocalizedMessage());
          }
        }
        break;
    }
    super.onActivityResult(requestCode, resultCode, data);
  }
  @Override
  public void onClick(View v) {
    if (entry == null) {
      return;
    }

    switch (entry.getState()) {
      case ThemeEntry.STATE_UNINSTALLED:
        Uri uri = Uri.parse("market://search?q=pname:" + entry.getPackageName());
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        try {
          v.getContext().startActivity(intent);
        } catch (ActivityNotFoundException e) {
          uri = Uri.parse(entry.getFileUrl());
          intent.setData(uri);
          v.getContext().startActivity(intent);
        }
        break;
      case ThemeEntry.STATE_INSTALLED:
        useTheme(v.getContext());
        break;
      case ThemeEntry.STATE_USING:
        break;
    }
  }
예제 #6
0
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK || resultCode == Activity.RESULT_CANCELED) {
      switch (requestCode) {
        case ACTION_REQUEST_FEATHER:
          Uri mImageUri = data.getData();
          Boolean mChanged = data.getBooleanExtra("EXTRA_OUT_BITMAP_CHANGED", false);

          try {
            JSONObject returnVal = new JSONObject();
            // returnVal.put("changed", mChanged); // doesn't ever seem to be anything other than
            // false

            if (mImageUri != null) {
              returnVal.put("src", mImageUri.toString());
              returnVal.put("name", mImageUri.getLastPathSegment());
            }

            this.callbackContext.success(returnVal);
          } catch (JSONException ex) {
            Log.e(LOG_TAG, ex.toString());
            this.callbackContext.error(ex.getMessage());
          }
          break;
      }
    }
  }
  public static IntentDataParameters parseData(Context context, Uri data) {
    IntentDataParameters parameters = new IntentDataParameters();

    // transaction type
    String transactionTypeName = data.getQueryParameter(PARAM_TRANSACTION_TYPE);
    TransactionTypes type = TransactionTypes.valueOf(transactionTypeName);
    if (type != null) parameters.transactionType = type;

    // account
    String accountName = data.getQueryParameter(PARAM_ACCOUNT);
    if (accountName != null) {
      AccountRepository account = new AccountRepository(context);
      int accountId = account.loadIdByName(accountName);
      parameters.accountId = accountId;
    }

    parameters.payeeName = data.getQueryParameter(PARAM_PAYEE);
    if (parameters.payeeName != null) {
      PayeeService payee = new PayeeService(context);
      int payeeId = payee.loadIdByName(parameters.payeeName);
      parameters.payeeId = payeeId;
    }

    String amount = data.getQueryParameter(PARAM_AMOUNT);
    parameters.amount = MoneyFactory.fromString(amount);

    parameters.categoryName = data.getQueryParameter(PARAM_CATEGORY);
    if (parameters.categoryName != null) {
      CategoryService category = new CategoryService(context);
      int categoryId = category.loadIdByName(parameters.categoryName);
      parameters.categoryId = categoryId;
    }

    return parameters;
  }
  protected void toggleBoughtItem() {
    if (mSentItemId != null) {

      Uri uri = Uri.withAppendedPath(Contains.CONTENT_URI, mSentItemId);
      toggleBoughtItem(uri.toString());
    }
  }
  public static void PublishUnreadCount(Context context) {
    try {
      // Check if TeslaUnread is installed before doing some expensive database query
      ContentValues cv = new ContentValues();
      cv.put("tag", "de.luhmer.owncloudnewsreader/de.luhmer.owncloudnewsreader");
      cv.put("count", 0);
      context
          .getContentResolver()
          .insert(Uri.parse("content://com.teslacoilsw.notifier/unread_count"), cv);

      // If we get here.. TeslaUnread is installed
      DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(context);
      int count =
          Integer.parseInt(
              dbConn.getUnreadItemsCountForSpecificFolder(
                  SubscriptionExpandableListAdapter.SPECIAL_FOLDERS.ALL_UNREAD_ITEMS));

      cv.put("count", count);
      context
          .getContentResolver()
          .insert(Uri.parse("content://com.teslacoilsw.notifier/unread_count"), cv);
    } catch (IllegalArgumentException ex) {
      /* Fine, TeslaUnread is not installed. */
    } catch (Exception ex) {
      /* Some other error, possibly because the format of the ContentValues are incorrect.
      Log but do not crash over this. */

      ex.printStackTrace();
    }
  }
 @Override
 public Cursor query(
     Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
   SQLiteDatabase db = dbHelper.getReadableDatabase();
   Cursor cursor = null;
   switch (uriMatcher.match(uri)) {
     case BOOK_DIR:
       cursor = db.query("Book", projection, selection, selectionArgs, null, null, sortOrder);
       break;
     case BOOK_ITEM:
       String bookId = uri.getPathSegments().get(1);
       cursor =
           db.query("Book", projection, "id = ?", new String[] {bookId}, null, null, sortOrder);
       break;
     case CATEGORY_DIR:
       cursor = db.query("Category", projection, selection, selectionArgs, null, null, sortOrder);
       break;
     case CATEGORY_ITEM:
       String categoryId = uri.getPathSegments().get(1);
       cursor =
           db.query(
               "Category", projection, "id = ?", new String[] {categoryId}, null, null, sortOrder);
       break;
     default:
       break;
   }
   return cursor;
 }
예제 #11
0
  public void setCaptImage(Uri ur, int src) {
    BitMapManipulation bm = new BitMapManipulation();
    // String path;
    switch (imgIdG) {
      case 0:
        captView[0].findViewById(R.id.captBtn1).setVisibility(View.GONE);
        captImg[0].setVisibility(View.VISIBLE);
        captImg[0].setLongClickable(true);
        captImg[0].setOnTouchListener(this);

        if (captImg[0] != null) {
          captImg[0].destroyDrawingCache();
        }
        System.gc();
        Runtime.getRuntime().gc();
        bmp[0] = bm.createBMP(src, ur.toString(), captImg[0].getWidth(), captImg[0].getHeight());
        resetView(captImg[0]);
        captImg[0].setImageBitmap(bmp[0]);
        captImg[0].invalidate();

        Toast.makeText(this, "id: " + imgIdG, Toast.LENGTH_SHORT).show();
        break;
      case 1:
        if (MAX_COL == 1) {
          captView[1].findViewById(R.id.captBtn1).setVisibility(View.GONE);
          captImg[1].setVisibility(View.VISIBLE);
          captImg[1].setOnTouchListener(this);
          bmp[1] = bm.createBMP(src, ur.toString(), captImg[0].getWidth(), captImg[0].getHeight());
          resetView(captImg[1]);
          captImg[1].setImageBitmap(bmp[1]);
        } else {
          captView[0].findViewById(R.id.captBtn2).setVisibility(View.GONE);
          captImg[1].setVisibility(View.VISIBLE);
          captImg[1].setOnTouchListener(this);
          bmp[1] = bm.createBMP(src, ur.toString(), captImg[0].getWidth(), captImg[0].getHeight());
          resetView(captImg[1]);
          captImg[1].setImageBitmap(bmp[1]);
        }
        Toast.makeText(this, "id: " + imgIdG, Toast.LENGTH_SHORT).show();
        break;
      case 2:
        captView[1].findViewById(R.id.captBtn1).setVisibility(View.GONE);
        captImg[2].setVisibility(View.VISIBLE);
        captImg[2].setOnTouchListener(this);
        bmp[2] = bm.createBMP(src, ur.toString(), captImg[2].getWidth(), captImg[2].getHeight());
        resetView(captImg[2]);
        captImg[2].setImageBitmap(bmp[2]);
        break;
      case 3:
        captView[1].findViewById(R.id.captBtn2).setVisibility(View.GONE);
        captImg[3].setVisibility(View.VISIBLE);
        captImg[3].setOnTouchListener(this);
        bmp[3] = bm.createBMP(src, ur.toString(), captImg[0].getWidth(), captImg[0].getHeight());
        resetView(captImg[3]);
        captImg[3].setImageBitmap(bmp[3]);
        break;
    }
    System.gc();
    Runtime.getRuntime().gc();
  }
  private void openPreferredLocationInMap() {
    // Using the URI scheme for showing a location found on a map.  This super-handy
    // intent can is detailed in the "Common Intents" page of Android's developer site:
    // http://developer.android.com/guide/components/intents-common.html#Maps
    if (null != mForecastAdapter) {
      Cursor c = mForecastAdapter.getCursor();
      if (null != c) {
        c.moveToPosition(0);
        String posLat = c.getString(COL_COORD_LAT);
        String posLong = c.getString(COL_COORD_LONG);
        Uri geoLocation = Uri.parse("geo:" + posLat + "," + posLong);

        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(geoLocation);

        if (intent.resolveActivity(getActivity().getPackageManager()) != null) {
          startActivity(intent);
        } else {
          Log.d(
              LOG_TAG,
              "Couldn't call " + geoLocation.toString() + ", no receiving apps installed!");
        }
      }
    }
  }
 private boolean e()
 {
   try
   {
     String str = Uri.decode(u.toString());
     if (str.startsWith("http://"))
     {
       str = str.substring("http://".length());
       int i1 = str.indexOf("/");
       if (i1 > 0)
       {
         if (!str.substring(0, i1).startsWith("127.0.0.1")) {
           return false;
         }
         str = ap.bH(str.substring(i1));
         Intent localIntent = new Intent(this, StreamingMediaPlayer.class);
         localIntent.addFlags(67108864);
         localIntent.setData(Uri.parse(str));
         startActivity(localIntent);
         return true;
       }
     }
   }
   catch (Exception localException) {}
   return false;
 }
 static Set<BarcodeFormat> parseDecodeFormats(Uri inputUri) {
   List<String> formats = inputUri.getQueryParameters(QRcodeIntents.Scan.FORMATS);
   if (formats != null && formats.size() == 1 && formats.get(0) != null) {
     formats = Arrays.asList(COMMA_PATTERN.split(formats.get(0)));
   }
   return parseDecodeFormats(formats, inputUri.getQueryParameter(QRcodeIntents.Scan.MODE));
 }
예제 #15
0
  /**
   * Writes Facebook profile information into preferences
   *
   * @param profile Facebook profile
   */
  private void writeProfileToPrefs(@Nullable Profile profile) {
    if (profile != null) {
      String id = profile.getId();
      String name = profile.getName();
      String firstName = profile.getFirstName();
      String lastName = profile.getLastName();
      Uri profileUri = profile.getLinkUri();
      Uri profilePictureUri = profile.getProfilePictureUri(100, 100);

      Resources res = LoginActivity.this.getResources();
      SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
      SharedPreferences.Editor editor = prefs.edit();

      editor.putBoolean(res.getString(R.string.pref_fb_logged_in), true);
      editor.putString(res.getString(R.string.pref_fb_facebook_id), id);
      editor.putString(res.getString(R.string.pref_fb_username), name);
      editor.putString(res.getString(R.string.pref_fb_firstname), firstName);
      editor.putString(res.getString(R.string.pref_fb_lastname), lastName);
      editor.putString(
          res.getString(R.string.pref_fb_email), id + res.getString(R.string.at_weconnect_berlin));
      editor.putString(res.getString(R.string.pref_fb_profile_uri), profileUri.getPath());
      editor.putString(
          res.getString(R.string.pref_fb_profile_picture_uri), profilePictureUri.getPath());
      editor.apply();
    }
  }
예제 #16
0
 public List<SMSBean> getThreads(int number) {
   Cursor cursor = null;
   ContentResolver contentResolver = mContext.getContentResolver();
   List<SMSBean> list = new ArrayList<SMSBean>();
   try {
     if (number > 0) {
       cursor =
           contentResolver.query(
               Uri.parse(CONTENT_URI_SMS_CONVERSATIONS),
               THREAD_COLUMNS,
               null,
               null,
               "thread_id desc limit " + number);
     } else {
       cursor =
           contentResolver.query(
               Uri.parse(CONTENT_URI_SMS_CONVERSATIONS), THREAD_COLUMNS, null, null, "date desc");
     }
     if (cursor == null || cursor.getCount() == 0) return list;
     for (int i = 0; i < cursor.getCount(); i++) {
       cursor.moveToPosition(i);
       SMSBean mmt =
           new SMSBean(cursor.getString(0), cursor.getString(1), cursor.getString(2), false);
       list.add(mmt);
     }
     return list;
   } catch (Exception e) {
     return list;
   }
 }
예제 #17
0
  @Override
  public Cursor query(
      Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {

    Log.e("appstorequery", "uri is " + uri.toString());
    Log.e("appstorequery", "seletcion is " + selection);
    Log.e("appstorequery", "selectionArgs is " + selectionArgs[0]);
    Log.e("appstorequery", "selectionArgs is " + selectionArgs[1]);

    selection = "url=? AND service_name=?";
    selectionArgs = new String[] {"http://www.baidu.com/1", "service1"};

    switch (uriMatcher.match(uri)) {
      case ITEMS:
        // Log.d("appstorequery", "uri is ITEMS ");
        return database.query(
            TABLE_URL_PERMISSIONS, projection, selection, selectionArgs, null, null, sortOrder);
      case ITEM:
        // Log.d("appstorequery", "uri is ITEM ");
        return database.query(
            TABLE_URL_PERMISSIONS,
            projection,
            _ID + "=" + uri.getPathSegments().get(1),
            selectionArgs,
            null,
            null,
            null);
      default:
        throw new IllegalArgumentException("unknown uri: " + uri);
    }
  }
예제 #18
0
 private void galleryAddPic(Uri uri) {
   Intent mediaScanIntent = new Intent("android.intent.action.MEDIA_SCANNER_SCAN_FILE");
   File f = new File(uri.getPath());
   Uri contentUri = Uri.fromFile(f);
   mediaScanIntent.setData(contentUri);
   this.sendBroadcast(mediaScanIntent);
 }
 /**
  * Constructs a new UriBuilder from the given Uri.
  *
  * @return a new Uri Builder based off the given Uri.
  */
 public static UriBuilder newInstance(Uri uri) {
   return new UriBuilder()
       .scheme(uri.getScheme())
       .host(uri.getHost())
       .path(uri.getPath())
       .query(uri.getQuery());
 }
예제 #20
0
  @Override
  public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) {
    Uri baseUri;
    if (cursorFilter != null) {
      baseUri = Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI, Uri.encode(cursorFilter));
    } else {
      baseUri = Contacts.CONTENT_URI;
    }

    String select =
        "(("
            + Contacts.DISPLAY_NAME
            + " NOTNULL) AND ("
            + Contacts.HAS_PHONE_NUMBER
            + "=1) AND ("
            + Contacts.DISPLAY_NAME
            + " != '' ))";

    String[] projection =
        new String[] {
          Contacts._ID,
          Contacts.DISPLAY_NAME,
          Contacts.CONTACT_STATUS,
          Contacts.CONTACT_PRESENCE,
          Contacts.PHOTO_ID,
          Contacts.LOOKUP_KEY,
        };

    CursorLoader cursorLoader =
        new CursorLoader(
            ContactSearchActivity_2.this, baseUri, projection, select, null, Contacts.DISPLAY_NAME);

    return cursorLoader;
  }
예제 #21
0
  @Override
  public Cursor query(
      Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    Cursor result = null;
    if (URI_ITEMS.equals(uri)) {
      result =
          DatabaseHandler.getInstance(getContext())
              .getReadableDatabase()
              .query(Item.TABLE_NAME, Item.FIELDS, null, null, null, null, null, null);
      result.setNotificationUri(getContext().getContentResolver(), URI_ITEMS);
    } else if (uri.toString().startsWith(ITEM_BASE)) {
      final long id = Long.parseLong(uri.getLastPathSegment());
      result =
          DatabaseHandler.getInstance(getContext())
              .getReadableDatabase()
              .query(
                  Item.TABLE_NAME,
                  Item.FIELDS,
                  Item._ID + " IS ?",
                  new String[] {String.valueOf(id)},
                  null,
                  null,
                  null,
                  null);
      result.setNotificationUri(getContext().getContentResolver(), URI_ITEMS);
    } else {
      throw new UnsupportedOperationException("Not yet implemented");
    }

    return result;
  }
예제 #22
0
 private Uri getOutputMediaFileUri(int theMediaType) {
   if (isExternalStorageAvailable()) {
     // get the Uri
     // 1. Get external storage directory
     String appName = getString(R.string.app_name);
     File mediaStorageDir =
         new File(
             Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
             appName);
     // 2. Create our subdirectory
     if (!mediaStorageDir.exists()) {
       if (!mediaStorageDir.mkdirs()) {
         Log.e("ProfileFragment", "Failed to get directory");
       }
     }
     // 3. Create a file name
     // 4. Create the file
     File mediaFile;
     Date now = new Date();
     String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(now);
     String path = mediaStorageDir.getPath() + File.separator;
     if (theMediaType == MEDIA_TYPE_IMAGE) {
       mediaFile = new File(path + "IMG_" + timeStamp + ".jpg");
     } // else if video type...but i'm not using videos here so this is good enough.
     else {
       Log.d("ProfileFragment", "file path is null");
       return null;
     }
     Log.d("ProfileFragment", "File: " + Uri.fromFile(mediaFile));
     // 5. Return the files Uri
     return Uri.fromFile(mediaFile);
   } else {
     return null;
   }
 }
  /**
   * Handle the specified CALL or CALL_* intent on a non-voice-capable device.
   *
   * <p>This method may launch a different intent (if there's some useful alternative action to
   * take), or otherwise display an error dialog, and in either case will finish() the current
   * activity when done.
   */
  private void handleNonVoiceCapable(Intent intent) {
    if (DBG)
      Log.v(TAG, "handleNonVoiceCapable: handling " + intent + " on non-voice-capable device...");
    String action = intent.getAction();
    Uri uri = intent.getData();
    String scheme = uri.getScheme();

    // Handle one special case: If this is a regular CALL to a tel: URI,
    // bring up a UI letting you do something useful with the phone number
    // (like "Add to contacts" if it isn't a contact yet.)
    //
    // This UI is provided by the contacts app in response to a DIAL
    // intent, so we bring it up here by demoting this CALL to a DIAL and
    // relaunching.
    //
    // TODO: it's strange and unintuitive to manually launch a DIAL intent
    // to do this; it would be cleaner to have some shared UI component
    // that we could bring up directly.  (But for now at least, since both
    // Contacts and Phone are built-in apps, this implementation is fine.)

    if (Intent.ACTION_CALL.equals(action) && (Constants.SCHEME_TEL.equals(scheme))) {
      Intent newIntent = new Intent(Intent.ACTION_DIAL, uri);
      if (DBG) Log.v(TAG, "- relaunching as a DIAL intent: " + newIntent);
      startActivity(newIntent);
      finish();
      return;
    }

    // In all other cases, just show a generic "voice calling not
    // supported" dialog.
    showDialog(DIALOG_NOT_VOICE_CAPABLE);
    // ...and we'll eventually finish() when the user dismisses
    // or cancels the dialog.
  }
 public static URI getAuthorizationUrl(
     URI loginServer,
     String clientId,
     String callbackUrl,
     String[] scopes,
     String clientSecret,
     String displayType) {
   if (displayType == null) displayType = "touch";
   final StringBuilder sb = new StringBuilder(loginServer.toString());
   sb.append(OAUTH_AUTH_PATH);
   sb.append(displayType);
   if (clientSecret != null) {
     sb.append("&").append(RESPONSE_TYPE).append("=").append(ACTIVATED_CLIENT_CODE);
   } else {
     sb.append("&").append(RESPONSE_TYPE).append("=").append(TOKEN);
   }
   sb.append("&").append(CLIENT_ID).append("=").append(Uri.encode(clientId));
   if ((null != scopes) && (scopes.length > 0)) {
     // need to always have the refresh_token scope to reuse our refresh token
     sb.append("&").append(SCOPE).append("=").append(REFRESH_TOKEN);
     StringBuilder scopeStr = new StringBuilder();
     for (String scope : scopes) {
       if (!scope.equalsIgnoreCase(REFRESH_TOKEN)) {
         scopeStr.append(" ").append(scope);
       }
     }
     String safeScopeStr = Uri.encode(scopeStr.toString());
     sb.append(safeScopeStr);
   }
   sb.append("&redirect_uri=");
   sb.append(callbackUrl);
   return URI.create(sb.toString());
 }
예제 #25
0
  public void setAsCurrent() {
    if (mUri == null) {
      return;
    }
    Cursor cur = mContext.getContentResolver().query(mUri, null, null, null, null);
    cur.moveToFirst();
    int index = cur.getColumnIndex("_id");
    String apnId = cur.getString(index);
    cur.close();

    ContentValues values = new ContentValues();
    values.put("apn_id", apnId);
    if (mSlot == -1) {
      mContext
          .getContentResolver()
          .update(Uri.parse("content://telephony/carriers/preferapn"), values, null, null);
    } else {
      int simNo = mSlot + 1;
      mContext
          .getContentResolver()
          .update(
              Uri.parse("content://telephony/carriers_sim" + simNo + "/preferapn"),
              values,
              null,
              null);
    }
  }
예제 #26
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    textView = (TextView) findViewById(R.id.textView);

    Intent intent = getIntent();
    String name = "";
    String age = "";
    if (intent != null) {
      /** ************通过intent启动****************** */
      name = intent.getStringExtra("name");
      age = intent.getStringExtra("age");
      String action = intent.getAction();

      /** ************通过scheme 启动****************** */
      if (Intent.ACTION_VIEW.equals(action)) {
        Uri uri = intent.getData();
        if (uri != null) {
          name = uri.getQueryParameter("name");
          age = uri.getQueryParameter("age");
        }
      }
      textView.setText(name + "\n" + age);
    }
  }
예제 #27
0
  public static final class Activities implements BaseColumns, ActivitiesColumns {
    /** This utility class cannot be instantiated */
    private Activities() {}

    /** The content:// style URI for this table */
    public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "activities");

    /**
     * The content:// URI for this table filtered to the set of social activities authored by a
     * specific {@link android.provider.ContactsContract.Contacts#_ID}.
     */
    public static final Uri CONTENT_AUTHORED_BY_URI =
        Uri.withAppendedPath(CONTENT_URI, "authored_by");

    /**
     * The {@link Uri} for the latest social activity performed by any raw contact aggregated under
     * the specified {@link Contacts#_ID}. Will also join with most-present {@link Presence} for
     * this aggregate.
     */
    public static final Uri CONTENT_CONTACT_STATUS_URI =
        Uri.withAppendedPath(AUTHORITY_URI, "contact_status");

    /** The MIME type of {@link #CONTENT_URI} providing a directory of social activities. */
    public static final String CONTENT_TYPE = "vnd.android.cursor.dir/activity";

    /** The MIME type of a {@link #CONTENT_URI} subdirectory of a single social activity. */
    public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/activity";
  }
 public boolean shouldOverrideUrlLoading(WebView webView, String url) {
   com.google.ads.util.b.a("shouldOverrideUrlLoading(\"" + url + "\")");
   Uri parse = Uri.parse(url);
   HashMap b = AdUtil.b(parse);
   if (b != null) {
     String str = (String) b.get("ai");
     if (str != null) {
       this.a.l().a(str);
     }
   }
   if (c.a(parse)) {
     c.a(this.a, this.d, parse, webView);
     return true;
   } else if (this.f) {
     if (AdUtil.a(parse)) {
       return super.shouldOverrideUrlLoading(webView, url);
     }
     b = new HashMap();
     b.put(AdActivity.URL_PARAM, url);
     AdActivity.launchAdActivity(this.a, new e("intent", b));
     return true;
   } else if (this.e) {
     b = new HashMap();
     b.put(AdActivity.URL_PARAM, parse.toString());
     AdActivity.launchAdActivity(this.a, new e("intent", b));
     return true;
   } else {
     com.google.ads.util.b.e("URL is not a GMSG and can't handle URL: " + url);
     return true;
   }
 }
예제 #29
0
 /**
  * Do a geo search using the address as the query.
  *
  * @param address The address to find
  * @param title An optional title, e.g. the name of the business at this address
  */
 final void searchMap(String address, CharSequence title) {
   String query = address;
   if (title != null && title.length() > 0) {
     query += " (" + title + ')';
   }
   launchIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=" + Uri.encode(query))));
 }
 private void handleSendDraftIntent(Intent intent) {
   final Uri uri = intent.getData();
   if (uri == null) return;
   final long draftId = ParseUtils.parseLong(uri.getLastPathSegment(), -1);
   if (draftId == -1) return;
   final Expression where = Expression.equals(Drafts._ID, draftId);
   final Cursor c =
       getContentResolver().query(Drafts.CONTENT_URI, Drafts.COLUMNS, where.getSQL(), null, null);
   final DraftItem.CursorIndices i = new DraftItem.CursorIndices(c);
   final DraftItem item;
   try {
     if (!c.moveToFirst()) return;
     item = new DraftItem(c, i);
   } finally {
     c.close();
   }
   if (item.action_type == Drafts.ACTION_UPDATE_STATUS || item.action_type <= 0) {
     updateStatuses(new ParcelableStatusUpdate(this, item));
   } else if (item.action_type == Drafts.ACTION_SEND_DIRECT_MESSAGE) {
     final long recipientId = item.action_extras.optLong(EXTRA_RECIPIENT_ID);
     if (item.account_ids == null || item.account_ids.length <= 0 || recipientId <= 0) {
       return;
     }
     final long accountId = item.account_ids[0];
     final String imageUri =
         item.media != null && item.media.length > 0 ? item.media[0].uri : null;
     sendMessage(accountId, recipientId, item.text, imageUri);
   }
 }