@SuppressLint("JavascriptInterface")
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);
    Activity activity = this.getActivity();
    appBarLayout = (CollapsingToolbarLayout) activity.findViewById(R.id.toolbar_layout);
    Intent i_getvalue = activity.getIntent();
    String action = i_getvalue.getAction();

    if (Intent.ACTION_VIEW.equals(action)) {
      Uri uri = i_getvalue.getData();
      if (uri != null) {
        String title = uri.getQueryParameter("title");
        postid = uri.getQueryParameter("postid");
        appBarLayout.setTitle(title); // 设置文章标题
      }
    } else if (getArguments().containsKey(ARG_ITEM_ID)) {
      // Load the models rawData specified by the fragment
      // arguments. In a real-world scenario, use a Loader
      // to load rawData from a rawData provider.
      postid = getArguments().getString(ARG_ITEM_ID);
      String title = getArguments().getString(ARG_POST_TITLE);
      appBarLayout.setTitle(title); // 设置文章标题
      SinglePostActivity.shareTitle = title;
    }
  }
  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;
  }
示例#3
0
  @Override
  public Cursor query(
      Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    // This is a simplified version extracted from MediaProvider.

    String tableName = getTableName(uri);
    if (tableName == null) return null;

    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
    qb.setTables(tableName);

    String groupBy = null;
    String limit = uri.getQueryParameter("limit");

    if (uri.getQueryParameter("distinct") != null) {
      qb.setDistinct(true);
    }

    Log.v(
        TAG,
        "query = "
            + qb.buildQuery(projection, selection, selectionArgs, groupBy, null, sortOrder, limit));

    if (selectionArgs != null) {
      for (String s : selectionArgs) {
        Log.v(TAG, "  selectionArgs = " + s);
      }
    }

    Cursor c =
        qb.query(mDatabase, projection, selection, selectionArgs, groupBy, null, sortOrder, limit);

    return c;
  }
  // Determine if this URI appears to be for a Google search
  // and does not have an RLZ parameter.
  // Taken largely from Chrome source, src/chrome/browser/google_url_tracker.cc
  private static boolean needsRlzString(Uri uri) {
    String scheme = uri.getScheme();
    if (("http".equals(scheme) || "https".equals(scheme))
        && (uri.getQueryParameter("q") != null)
        && (uri.getQueryParameter("rlz") == null)) {
      String host = uri.getHost();
      if (host == null) {
        return false;
      }
      String[] hostComponents = host.split("\\.");

      if (hostComponents.length < 2) {
        return false;
      }
      int googleComponent = hostComponents.length - 2;
      String component = hostComponents[googleComponent];
      if (!"google".equals(component)) {
        if (hostComponents.length < 3 || (!"co".equals(component) && !"com".equals(component))) {
          return false;
        }
        googleComponent = hostComponents.length - 3;
        if (!"google".equals(hostComponents[googleComponent])) {
          return false;
        }
      }

      // Google corp network handling.
      if (googleComponent > 0 && "corp".equals(hostComponents[googleComponent - 1])) {
        return false;
      }

      return true;
    }
    return false;
  }
示例#5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Set "mode" in route params
    try {
      routeParams.put("mode", "play");
    } catch (JSONException e) {
      // do nothing
    }

    // Get data from deep link (if available)
    Intent intent = getIntent();
    Uri data = intent.getData();

    // Set route params if valid deep link
    if (data == null) return;
    final String user = data.getQueryParameter("user");
    final String project = data.getQueryParameter("project");
    if (user == null || project == null) return;
    try {
      routeParams.put("user", user);
      routeParams.put("project", project);
    } catch (JSONException e) {
      // do nothing
    }
  }
示例#6
0
 protected void parseLaunchIntentLocation() {
   Intent intent = getIntent();
   if (intent != null && intent.getData() != null) {
     Uri data = intent.getData();
     if ("http".equalsIgnoreCase(data.getScheme())
         && "download.osmand.net".equals(data.getHost())
         && "/go".equals(data.getPath())) {
       String lat = data.getQueryParameter("lat");
       String lon = data.getQueryParameter("lon");
       if (lat != null && lon != null) {
         try {
           double lt = Double.parseDouble(lat);
           double ln = Double.parseDouble(lon);
           String zoom = data.getQueryParameter("z");
           int z = settings.getLastKnownMapZoom();
           if (zoom != null) {
             z = Integer.parseInt(zoom);
           }
           settings.setMapLocationToShow(lt, ln, z, getString(R.string.shared_location));
         } catch (NumberFormatException e) {
         }
       }
     }
   }
 }
示例#7
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);
    }
  }
示例#8
0
    public PublicURLProcessor(Uri uri)
    {
        mUri = uri;
        mHost = mUri.getHost();
        if (!Util.isEmpty(mHost))
        {
            mHost = mHost.toLowerCase();
        }
        mPathSegments = mUri.getPathSegments();
        mRefmarker = mUri.getQueryParameter("ref");
        mAssociateTag = mUri.getQueryParameter("tag");
        mLocaleName = getLocaleNameFromUri(uri);
        mParams = new HashMap();
        String s;
        boolean flag;
        if (android.os.Build.VERSION.SDK_INT >= 11)
        {
            flag = true;
        } else
        {
            flag = false;
        }
        if (flag)
        {
            uri = mUri.getQueryParameterNames();
        } else
        {
            uri = parseQueryParameterNames(mUri);
        }
        for (uri = uri.iterator(); uri.hasNext(); mParams.put(s, mUri.getQueryParameter(s)))
        {
            s = (String)uri.next();
        }

    }
 public static String b(Uri paramUri) {
   if (paramUri == null) {
     return "";
   }
   if (TextUtils.equals((CharSequence) paramUri.getPathSegments().get(0), "biz")) {
     return paramUri.getQueryParameter("photo_id");
   }
   return paramUri.getQueryParameter("select");
 }
 @Override
 protected void onNewIntent(Intent intent) {
   super.onNewIntent(intent);
   Uri uri = intent.getData();
   if (uri != null && uri.toString().startsWith("callback://com.yassirh.digitalocean")) {
     tokenEditText.setText(uri.getQueryParameter("code"));
     accountNameEditText.setText(uri.getQueryParameter("account_name"));
   }
 }
  private void parseOtpPath() {
    String otpauth = getIntent().getStringExtra("otpauth");
    Uri otpUri = Uri.parse(otpauth);

    name = otpUri.getQueryParameter("");
    secret = otpUri.getQueryParameter("secret");

    totp = new Totp(secret);
  }
示例#12
0
  public void handleNotificationIntent(Intent i) {
    final Uri data = i.getData();
    if (data == null) {
      Log.e(LOGTAG, "handleNotificationEvent: empty data");
      return;
    }
    final String id = data.getQueryParameter(ID_ATTR);
    final String notificationType = data.getQueryParameter(EVENT_TYPE_ATTR);
    if (id == null || notificationType == null) {
      Log.e(LOGTAG, "handleNotificationEvent: invalid intent parameters");
      return;
    }

    // In case the user swiped out the notification, we empty the id set.
    if (CLEARED_EVENT.equals(notificationType)) {
      mClearableNotifications.remove(id);
      // If Gecko isn't running, we throw away events where the notification was cancelled.
      // i.e. Don't bug the user if they're just closing a bunch of notifications.
      if (!GeckoThread.checkLaunchState(GeckoThread.LaunchState.GeckoRunning)) {
        return;
      }
    }

    JSONObject args = new JSONObject();

    // The handler and cookie parameters are optional
    final String handler = data.getQueryParameter(HANDLER_ATTR);
    final String cookie = i.getStringExtra(COOKIE_ATTR);

    try {
      args.put(ID_ATTR, id);
      args.put(EVENT_TYPE_ATTR, notificationType);
      args.put(HANDLER_ATTR, handler);
      args.put(COOKIE_ATTR, cookie);

      if (BUTTON_EVENT.equals(notificationType)) {
        final String actionName = data.getQueryParameter(ACTION_ID_ATTR);
        args.put(ACTION_ID_ATTR, actionName);
      }

      Log.i(LOGTAG, "Send " + args.toString());
      GeckoAppShell.sendEventToGecko(
          GeckoEvent.createBroadcastEvent("Notification:Event", args.toString()));
    } catch (JSONException e) {
      Log.e(LOGTAG, "Error building JSON notification arguments.", e);
    }

    // If the notification was clicked, we are closing it. This must be executed after
    // sending the event to js side because when the notification is canceled no event can be
    // handled.
    if (CLICK_EVENT.equals(notificationType) && !i.getBooleanExtra(ONGOING_ATTR, false)) {
      hideNotification(id, handler, cookie);
    }
  }
  @Test
  public void testToUri_additionalParams() throws Exception {
    Map<String, String> additionalParams = new HashMap<>();
    additionalParams.put("my_param", "1234");
    additionalParams.put("another_param", "5678");
    AuthorizationRequest req = mRequestBuilder.setAdditionalParameters(additionalParams).build();

    Uri uri = req.toUri();
    assertThat(uri.getQueryParameter("my_param")).isEqualTo("1234");
    assertThat(uri.getQueryParameter("another_param")).isEqualTo("5678");
  }
示例#14
0
 public static String getExternalReferrer(Uri paramUri)
 {
   String str1 = paramUri.getQueryParameter("referrer");
   if (TextUtils.isEmpty(str1))
   {
     String str2 = paramUri.getQueryParameter("gclid");
     if (TextUtils.isEmpty(str2)) {
       return null;
     }
     str1 = Uri.encode("gclid=" + str2);
   }
   return str1;
 }
示例#15
0
 private void handleCustomIntentFromUri(Uri uri) {
   mMoPubView.adClicked();
   String action = uri.getQueryParameter("fnc");
   String adData = uri.getQueryParameter("data");
   Intent customIntent = new Intent(action);
   if (adData != null) customIntent.putExtra(EXTRA_AD_CLICK_DATA, adData);
   try {
     getContext().startActivity(customIntent);
   } catch (ActivityNotFoundException e) {
     Log.w(
         "MoPub",
         "Could not handle custom intent: " + action + ". Is your intent spelled correctly?");
   }
 }
 @Test
 public void testToUri_displayParam() {
   Uri uri = mRequestBuilder.setDisplay(AuthorizationRequest.Display.PAGE).build().toUri();
   assertThat(uri.getQueryParameterNames()).contains(AuthorizationRequest.PARAM_DISPLAY);
   assertThat(uri.getQueryParameter(AuthorizationRequest.PARAM_DISPLAY))
       .isEqualTo(AuthorizationRequest.Display.PAGE);
 }
示例#17
0
  /**
   * Obtains OAuth access tokens which can be used during entire communication process with Opera
   * Link server and invokes first synchronisation
   */
  public void grantAccess() {

    Uri uri = this.getIntent().getData();
    if (uri == null) {
      return;
    }

    String verifier = uri.getQueryParameter(LinkClient.OAUTH_VERIFIER);
    if (verifier == null) {
      return;
    }
    try {
      link.grantAccess(verifier);
      Log.i(SYNC_TAG, "Access granted");

      accessToken = link.getAccessToken();
      tokenSecret = link.getTokenSecret();
      Editor prefEditor = pref.edit();
      prefEditor.putString(ACCESS_TOKEN_PREF_KEY, accessToken);
      prefEditor.putString(TOKEN_SECRET_PREF_KEY, tokenSecret);

      prefEditor.commit();
      isConnected = true;

      syncItems();
    } catch (LinkAccessDeniedException e) {
      showToast("Access forbidden for access token " + accessToken);
      e.printStackTrace();
    } catch (LibOperaLinkException e) {
      e.printStackTrace();
    }
  }
 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));
 }
  private void fillData(@Nullable Intent intent, @NonNull TextView textView) {
    Uri data = intent == null ? null : intent.getData();
    if (data == null) {
      textView.setText(Printer.EMPTY);
      return;
    }

    Truss truss = new Truss();
    Printer.append(truss, "raw", data);
    Printer.append(truss, "scheme", data.getScheme());
    Printer.append(truss, "host", data.getHost());
    Printer.append(truss, "port", data.getPort());
    Printer.append(truss, "path", data.getPath());
    Printer.appendKey(truss, "query");
    boolean query = false;
    if (data.isHierarchical()) {
      for (String queryParameterName : data.getQueryParameterNames()) {
        Printer.appendSecondary(
            truss, queryParameterName, data.getQueryParameter(queryParameterName));
        query = true;
      }
    }
    if (!query) {
      Printer.appendValue(truss, null);
    }
    Printer.append(truss, "fragment", data.getFragment());
    textView.setText(truss.build());
  }
示例#20
0
      @Override
      public boolean shouldOverrideUrlLoading(WebView view, String url) {
        // Check if the given URL is the callback URL.
        if (url.startsWith(callbackUrl) == false) {
          // The URL is not the callback URL.
          return false;
        }

        // This web view is about to be redirected to the callback URL.
        if (isDebugEnabled()) {
          Log.d(TAG, "Detected the callback URL: " + url);
        }

        // Convert String to Uri.
        Uri uri = Uri.parse(url);

        // Get the value of the query parameter "oauth_verifier".
        // A successful response should contain the parameter.
        verifier = uri.getQueryParameter("oauth_verifier");

        if (isDebugEnabled()) {
          Log.d(TAG, "oauth_verifier = " + verifier);
        }

        // Notify that the the authorization step was done.
        notifyAuthorization();

        // Whether the callback URL is actually accessed or not
        // depends on the value of dummyCallbackUrl. If the
        // value of dummyCallbackUrl is true, the callback URL
        // is not accessed.
        return dummyCallbackUrl;
      }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.todo_create);
    ButterKnife.inject(this);

    mTodoManager = new TodoManager(this);

    setSupportActionBar((android.support.v7.widget.Toolbar) findViewById(R.id.toolbar));
    getSupportActionBar().setTitle(R.string.todo_create);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    Intent intent = getIntent();
    String action = intent.getAction();
    if (Intent.ACTION_VIEW.equals(action)) {
      Uri uri = intent.getData();
      if (uri != null) {
        mEditText.setText(uri.getQueryParameter("text"));
      }
    } else {
      Bundle extras = intent.getExtras();
      if (extras != null) {
        int id = (extras.containsKey(EXTRA_ID)) ? extras.getInt(EXTRA_ID) : -1;
        if (id != -1) {
          mTodo = mTodoManager.find(id);
          mEditText.setText(mTodo.getName());
          getSupportActionBar().setTitle(R.string.todo_update);
        }
      }
    }

    mEditText.setKeyEventListener(this);
    mEditText.addTextChangedListener(this);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
  }
 public static dvn a(Uri paramUri) {
   Object localObject = paramUri.getPathSegments();
   String str = (String) ((List) localObject).get(0);
   List localList = paramUri.getQueryParameters("contentType");
   long l1 = Long.parseLong((String) ((List) localObject).get(2));
   long l2 = Long.parseLong((String) ((List) localObject).get(3));
   if (((List) localObject).size() >= 5) {
     localObject = (String) ((List) localObject).get(4);
     if (!((String) localObject).equals("empty")) {
       break label139;
     }
     dri.e(
         Attachment.a,
         "Parsed message attachment uri with partId = \"empty\"",
         new Object[] {paramUri});
   }
   label139:
   for (; ; ) {
     return new dvn(
         str,
         l1,
         Long.parseLong(paramUri.getQueryParameter("serverMessageId")),
         l2,
         (String) localObject,
         localList);
     localObject = null;
   }
 }
示例#23
0
  private boolean handleNativeBrowserScheme(String url) {
    if (!isNativeBrowserScheme(url)) {
      return false;
    }

    Uri uri = Uri.parse(url);

    String urlToOpenInNativeBrowser;
    try {
      urlToOpenInNativeBrowser = uri.getQueryParameter("url");
    } catch (UnsupportedOperationException e) {
      Log.w("Adcash", "Could not handle url: " + url);
      return false;
    }

    if (!"navigate".equals(uri.getHost()) || urlToOpenInNativeBrowser == null) {
      return false;
    }

    Uri intentUri = Uri.parse(urlToOpenInNativeBrowser);

    Intent intent = new Intent(Intent.ACTION_VIEW, intentUri);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    String errorMessage =
        "Could not handle intent with URI: " + url + ". Is this intent supported on your phone?";

    launchIntentForUserClick(mContext, intent, errorMessage);

    return true;
  }
  /**
   * Overrided for Twitter support
   *
   * @param requestCode The integer request code originally supplied to startActivityForResult(),
   *     allowing you to identify who this result came from.
   * @param resultCode The integer result code returned by the child activity through its
   *     setResult().
   * @param data An Intent, which can return result data to the caller (various data can be attached
   *     to Intent "extras").
   */
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    int sanitizedRequestCode = requestCode & 0xFFFF;
    if (sanitizedRequestCode != REQUEST_AUTH) return;
    super.onActivityResult(requestCode, resultCode, data);

    Uri uri = data != null ? data.getData() : null;

    if (uri != null && uri.toString().startsWith(mRedirectURL)) {
      String verifier = uri.getQueryParameter(URL_TWITTER_OAUTH_VERIFIER);

      RequestLogin2AsyncTask requestLogin2AsyncTask = new RequestLogin2AsyncTask();
      mRequests.put(REQUEST_LOGIN2, requestLogin2AsyncTask);
      Bundle args = new Bundle();
      args.putString(RequestLogin2AsyncTask.PARAM_VERIFIER, verifier);
      requestLogin2AsyncTask.execute(args);
    } else {
      if (mLocalListeners.get(REQUEST_LOGIN) != null) {
        mLocalListeners
            .get(REQUEST_LOGIN)
            .onError(getID(), REQUEST_LOGIN, "incorrect URI returned: " + uri, null);
        mLocalListeners.remove(REQUEST_LOGIN);
      }
      /*
       *
       * No authentication challenges found
       * Relevant discussions can be found on the Internet at:
       * http://www.google.co.jp/search?q=8e063946 or
       * http://www.google.co.jp/search?q=ef59cf9f
       *
       * */
      initTwitterClient();
    }
  }
 @Test
 public void testToUri_scopeParam() {
   Uri uri = mRequestBuilder.setScope(AuthorizationRequest.Scope.EMAIL).build().toUri();
   assertThat(uri.getQueryParameterNames()).contains(AuthorizationRequest.PARAM_SCOPE);
   assertThat(uri.getQueryParameter(AuthorizationRequest.PARAM_SCOPE))
       .isEqualTo(AuthorizationRequest.Scope.EMAIL);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fun_app_with_twitter);

    mSharedPreferences = getSharedPreferences(Const.PREFERENCE_NAME, MODE_PRIVATE);
    getTweetButton = (Button) findViewById(R.id.getTweet);
    getTweetButton.setOnClickListener(this);
    buttonLogin = (Button) findViewById(R.id.twitterLogin);
    buttonLogin.setOnClickListener(this);
    keyword = (EditText) findViewById(R.id.keyword);

    if (!isConnected()) {
      buttonLogin.setText(R.string.label_connect);
    } else {
      buttonLogin.setText(R.string.label_disconnect);
    }

    /** Handle OAuth Callback */
    Uri uri = getIntent().getData();
    if (uri != null && uri.toString().startsWith(Const.CALLBACK_URL)) {
      String verifier = uri.getQueryParameter(Const.IEXTRA_OAUTH_VERIFIER);
      try {
        AccessToken accessToken = twitter.getOAuthAccessToken(requestToken, verifier);
        Editor e = mSharedPreferences.edit();
        e.putString(Const.PREF_KEY_TOKEN, accessToken.getToken());
        e.putString(Const.PREF_KEY_SECRET, accessToken.getTokenSecret());
        e.commit();
      } catch (Exception e) {
        // System.out.println(e.toString());
        Log.e(TAG, e.getMessage());
        Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
      }
    }
  }
示例#27
0
 /** {@inheritDoc} */
 @Override
 public Cursor query(
     final Uri uri,
     final String[] projection,
     final String selection,
     final String[] selectionArgs,
     final String sortOrder) {
   Log.d(TAG, "query(" + uri + ",..)");
   if (uri == null) {
     return null;
   }
   final String query = uri.getLastPathSegment();
   Log.d(TAG, "query: " + query);
   if (TextUtils.isEmpty(query) || query.equals(SearchManager.SUGGEST_URI_PATH_QUERY)) {
     return null;
   }
   final int limit = Utils.parseInt(uri.getQueryParameter("limit"), -1);
   Log.d(TAG, "limit: " + limit);
   final String[] proj =
       new String[] {
         "_id",
         "address as " + SearchManager.SUGGEST_COLUMN_TEXT_1,
         "body as " + SearchManager.SUGGEST_COLUMN_TEXT_2
       };
   final String where = "body like '%" + query + "%'";
   return new MergeCursor(
       new Cursor[] {
         this.getContext()
             .getContentResolver()
             .query(
                 SMS_URI, // .
                 proj, where, null, null)
       });
 }
  @Override
  public int bulkInsert(Uri uri, ContentValues[] values) {
    String table = uri.getLastPathSegment();
    SQLiteDatabase db = mSqLiteOpenHelper.getWritableDatabase();
    int res = 0;
    db.beginTransaction();
    try {
      for (ContentValues v : values) {
        long id = db.insert(table, null, v);
        db.yieldIfContendedSafely();
        if (id != -1) {
          res++;
        }
      }
      db.setTransactionSuccessful();
    } finally {
      db.endTransaction();
    }
    String notify;
    if (res != 0
        && ((notify = uri.getQueryParameter(QUERY_NOTIFY)) == null || "true".equals(notify))) {
      getContext().getContentResolver().notifyChange(uri, null);
    }

    return res;
  }
 @Test
 public void testToUri_promptParam() {
   Uri uri = mRequestBuilder.setPrompt(AuthorizationRequest.Prompt.CONSENT).build().toUri();
   assertThat(uri.getQueryParameterNames()).contains(AuthorizationRequest.PARAM_PROMPT);
   assertThat(uri.getQueryParameter(AuthorizationRequest.PARAM_PROMPT))
       .isEqualTo(AuthorizationRequest.Prompt.CONSENT);
 }
    /**
     * Retrieve the oauth_verifier, and store the oauth and oauth_token_secret for future API calls.
     */
    @Override
    protected Void doInBackground(Uri... params) {
      final Uri uri = params[0];
      final String oauth_verifier = uri.getQueryParameter(OAuth.OAUTH_VERIFIER);

      try {
        provider.retrieveAccessToken(consumer, oauth_verifier);

        final Editor edit = prefs.edit();
        edit.putString(OAuth.OAUTH_TOKEN, consumer.getToken());
        edit.putString(OAuth.OAUTH_TOKEN_SECRET, consumer.getTokenSecret());
        edit.commit();

        String token = prefs.getString(OAuth.OAUTH_TOKEN, "");
        String secret = prefs.getString(OAuth.OAUTH_TOKEN_SECRET, "");

        consumer.setTokenWithSecret(token, secret);
        context.startActivity(new Intent(context, TwitterActivity.class));

        executeAfterAccessTokenRetrieval();

        Log.i(TAG, "OAuth - Access Token Retrieved");

      } catch (Exception e) {
        Log.e(TAG, "OAuth - Access Token Retrieval Error", e);
      }

      return null;
    }