Пример #1
1
  @Override
  protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    Log.d("LB", "onNewIntent");
    if ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)
        != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) {
      contentView.closeDrawers();
    }

    if (intent.getAction() == Intent.ACTION_WEB_SEARCH
        || intent.getAction() == Intent.ACTION_VIEW) {
      if (intent.getDataString() != null) {
        int tabNumber =
            intent.getIntExtra("tabNumber", -1); // used if intent is coming from Lucid Browser

        if (tabNumber != -1 && tabNumber < webWindows.size()) {
          webWindows.get(tabNumber).loadUrl(intent.getDataString());
        } else tabNumber = -1;

        if (tabNumber == -1) {
          openURLInNewTab(intent.getDataString());
        }
      }
    }
  }
Пример #2
0
 private void switchToConversation(
     Conversation conversation, String text, String nick, boolean pm, boolean newTask) {
   Intent viewConversationIntent = new Intent(this, ConversationActivity.class);
   viewConversationIntent.setAction(Intent.ACTION_VIEW);
   viewConversationIntent.putExtra(ConversationActivity.CONVERSATION, conversation.getUuid());
   if (text != null) {
     viewConversationIntent.putExtra(ConversationActivity.TEXT, text);
   }
   if (nick != null) {
     viewConversationIntent.putExtra(ConversationActivity.NICK, nick);
     viewConversationIntent.putExtra(ConversationActivity.PRIVATE_MESSAGE, pm);
   }
   viewConversationIntent.setType(ConversationActivity.VIEW_CONVERSATION);
   if (newTask) {
     viewConversationIntent.setFlags(
         viewConversationIntent.getFlags()
             | Intent.FLAG_ACTIVITY_NEW_TASK
             | Intent.FLAG_ACTIVITY_SINGLE_TOP);
   } else {
     viewConversationIntent.setFlags(
         viewConversationIntent.getFlags() | Intent.FLAG_ACTIVITY_CLEAR_TOP);
   }
   startActivity(viewConversationIntent);
   finish();
 }
Пример #3
0
 @Override
 protected int initLayout() {
   Intent intent = getIntent();
   if (intent.getFlags() == LoginActivity.FORGET_PASS_CODE) {
     return R.layout.activity_forget_pass_layout;
   } else if (intent.getFlags() == LoginActivity.REGIST_CODE) {
     return R.layout.activity_regist_layout;
   }
   return 0;
 }
Пример #4
0
  @Override
  protected void onNewIntent(Intent intent) {
    if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) {
      // Don't repeat action if intent comes from history
      return;
    }

    String action = intent.getAction();
    if (action == null) {
      return;
    }

    if (action.equals(RemoteInterface.PRIVACT_OPEN_NEW_WINDOW)) {
      // New session was created, add an EmulatorView to match
      SessionList sessions = mTermSessions;
      if (sessions == null) {
        // Presumably populateViewFlipper() will do this later ...
        return;
      }
      int position = sessions.size() - 1;

      TermSession session = sessions.get(position);
      EmulatorView view = createEmulatorView(session);

      mViewFlipper.addView(view);
      onResumeSelectWindow = position;
    } else if (action.equals(RemoteInterface.PRIVACT_SWITCH_WINDOW)) {
      int target = intent.getIntExtra(RemoteInterface.PRIVEXTRA_TARGET_WINDOW, -1);
      if (target >= 0) {
        onResumeSelectWindow = target;
      }
    }
  }
Пример #5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.book_data);

    context = this;
    back = (Button) findViewById(R.id.backToContainerView);
    bookname = (TextView) findViewById(R.id.bookname);
    Intent intent = getIntent();
    if (intent.getFlags() == Intent.FLAG_ACTIVITY_NEW_TASK) {
      Bundle extras = intent.getExtras();
      if (extras != null) {
        String value = extras.getString(Constants.BOOK_NAME);
        bookname.setText(value);
        container = ContainerHolder.getInstance().get(extras.getLong(Constants.CONTAINER_ID));
        if (container == null) {
          finish();
          return;
        }
      }
    }

    initMetadata();
    initPageList();
    initBookmark();

    initListener();
  }
Пример #6
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);
   targetActivity = (EditText) findViewById(R.id.editText1);
   flags = (EditText) findViewById(R.id.editText2);
   cheatSheet = (EditText) findViewById(R.id.editText3);
   for (String item : flagsList) {
     cheatSheet.append(item);
     cheatSheet.append("\n");
   }
   Intent whoCalled = getIntent();
   helloView = ((TextView) findViewById(R.id.textView3));
   helloView.setTextColor(android.graphics.Color.WHITE);
   helloView.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
   helloView.setText("Flags: 0x" + Integer.toHexString(whoCalled.getFlags()));
   if (whoCalled.getExtras() != null) {
     boolean areErrors = whoCalled.getExtras().getBoolean("existErrors", false);
     if (areErrors) {
       helloView.append(" There were errors!");
       helloView.setTextColor(android.graphics.Color.RED);
       helloView.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
     }
   }
   //        actManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
   //        logSystemInfo();
   ActivityManager am = (ActivityManager) getSystemService(Service.ACTIVITY_SERVICE);
   List<ActivityManager.RunningAppProcessInfo> processes;
   processes = am.getRunningAppProcesses();
   for (ActivityManager.RunningAppProcessInfo info : processes) {
     Log.i("Process:", info.processName);
   }
 }
 // Gets the auth token synchronously
 private String getAuthTokenInner(
     AccountManagerFuture<Bundle> future, AtomicBoolean errorEncountered) {
   try {
     Bundle result = future.getResult();
     if (result != null) {
       if (result.containsKey(AccountManager.KEY_INTENT)) {
         Log.d(TAG, "Starting intent to get auth credentials");
         // Need to start intent to get credentials
         Intent intent = result.getParcelable(AccountManager.KEY_INTENT);
         int flags = intent.getFlags();
         flags |= Intent.FLAG_ACTIVITY_NEW_TASK;
         intent.setFlags(flags);
         mApplicationContext.startActivity(intent);
         return null;
       }
       return result.getString(AccountManager.KEY_AUTHTOKEN);
     } else {
       Log.w(TAG, "Auth token - getAuthToken returned null");
     }
   } catch (OperationCanceledException e) {
     Log.w(TAG, "Auth token - operation cancelled", e);
   } catch (AuthenticatorException e) {
     Log.w(TAG, "Auth token - authenticator exception", e);
   } catch (IOException e) {
     Log.w(TAG, "Auth token - IO exception", e);
     errorEncountered.set(true);
   }
   return null;
 }
Пример #8
0
  @TargetApi(VERSION_CODES.KITKAT)
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == READ_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
      // The document selected by the user won't be returned in the intent.
      // Instead, a URI to that document will be contained in the return intent
      // provided to this method as a parameter.
      // Pull that URI using resultData.getData().
      Uri uri = null;
      if (data != null) {
        uri = data.getData();
        int takeFlags =
            data.getFlags()
                & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
        // Check for the freshest data.

        getContentResolver().takePersistableUriPermission(uri, takeFlags);
        appSettingsManager.SetBaseFolder(uri.toString());
        if (resultCallback != null) {
          resultCallback.onActivityResultCallback(uri);
          resultCallback = null;
        }
      }
    }
  }
Пример #9
0
 @Test
 public void shouldSetFlags() throws Exception {
   Intent intent = new Intent();
   Intent self = intent.setFlags(1234);
   assertEquals(1234, intent.getFlags());
   assertSame(self, intent);
 }
  public List<R> queryIntentFromList(
      Intent intent, String resolvedType, boolean defaultOnly, ArrayList<F[]> listCut, int userId) {
    ArrayList<R> resultList = new ArrayList<R>();

    final boolean debug =
        localLOGV || ((intent.getFlags() & Intent.FLAG_DEBUG_LOG_RESOLUTION) != 0);

    FastImmutableArraySet<String> categories = getFastIntentCategories(intent);
    final String scheme = intent.getScheme();
    int N = listCut.size();
    for (int i = 0; i < N; ++i) {
      buildResolveList(
          intent,
          categories,
          debug,
          defaultOnly,
          resolvedType,
          scheme,
          listCut.get(i),
          resultList,
          userId);
    }
    sortResults(resultList);
    return resultList;
  }
  @SmallTest
  @Feature({"TextInput"})
  public void testSelectActionBarSearchAndShareLaunchesNewTask() throws Exception {
    DOMUtils.longPressNode(this, mContentViewCore, "textarea");
    assertWaitForSelectActionBarVisible(true);
    assertTrue(mContentViewCore.hasSelection());
    assertNotNull(mContentViewCore.getSelectActionHandler());
    selectActionBarSearch();
    Intent i = getActivity().getLastSentIntent();
    int new_task_flag = Intent.FLAG_ACTIVITY_NEW_TASK;
    assertEquals(i.getFlags() & new_task_flag, new_task_flag);

    selectActionBarShare();
    i = getActivity().getLastSentIntent();
    assertEquals(i.getFlags() & new_task_flag, new_task_flag);
  }
  private static void logIntent(int intentType, Intent intent, int callerUid, String resolvedType) {
    // The component shouldn't be null, but let's double check just to be safe
    ComponentName cn = intent.getComponent();
    String shortComponent = null;
    if (cn != null) {
      shortComponent = cn.flattenToShortString();
    }

    String callerPackages = null;
    int callerPackageCount = 0;
    IPackageManager pm = AppGlobals.getPackageManager();
    if (pm != null) {
      try {
        String[] callerPackagesArray = pm.getPackagesForUid(callerUid);
        if (callerPackagesArray != null) {
          callerPackageCount = callerPackagesArray.length;
          callerPackages = joinPackages(callerPackagesArray);
        }
      } catch (RemoteException ex) {
        Slog.e(TAG, "Remote exception while retrieving packages", ex);
      }
    }

    EventLogTags.writeIfwIntentMatched(
        intentType,
        shortComponent,
        callerUid,
        callerPackageCount,
        callerPackages,
        intent.getAction(),
        resolvedType,
        intent.getDataString(),
        intent.getFlags());
  }
Пример #13
0
 public void onAppPicked(ResolveInfo info) {
   final Intent intent = new Intent(getIntent());
   intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_FORWARD_RESULT);
   intent.setComponent(
       new ComponentName(info.activityInfo.applicationInfo.packageName, info.activityInfo.name));
   startActivityForResult(intent, CODE_FORWARD);
 }
Пример #14
0
  private void populateViewFlipper() {
    if (mTermService != null) {
      mTermSessions = mTermService.getSessions();
      mTermSessions.addCallback(this);

      if (mTermSessions.size() == 0) {
        mTermSessions.add(createTermSession());
      }

      for (TermSession session : mTermSessions) {
        EmulatorView view = createEmulatorView(session);
        mViewFlipper.addView(view);
      }

      updatePrefs();

      Intent intent = getIntent();
      int flags = intent.getFlags();
      String action = intent.getAction();
      if ((flags & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0 && action != null) {
        if (action.equals(RemoteInterface.PRIVACT_OPEN_NEW_WINDOW)) {
          mViewFlipper.setDisplayedChild(mTermSessions.size() - 1);
        } else if (action.equals(RemoteInterface.PRIVACT_SWITCH_WINDOW)) {
          int target = intent.getIntExtra(RemoteInterface.PRIVEXTRA_TARGET_WINDOW, -1);
          if (target >= 0) {
            mViewFlipper.setDisplayedChild(target);
          }
        }
      }

      mViewFlipper.resumeCurrentView();
    }
  }
Пример #15
0
 @Test
 public void shouldAddFlags() throws Exception {
   Intent intent = new Intent();
   Intent self = intent.addFlags(4);
   self.addFlags(8);
   assertEquals(12, intent.getFlags());
   assertSame(self, intent);
 }
Пример #16
0
  @Test
  public void startActivity_withActivityContext_shouldStartActivityWithNoNewFlags()
      throws IntentNotResolvableException {
    Intents.startActivity(activityContext, new Intent());

    final Intent intent = ShadowApplication.getInstance().peekNextStartedActivity();
    assertThat(Utils.bitMaskContainsFlag(intent.getFlags(), FLAG_ACTIVITY_NEW_TASK)).isFalse();
  }
Пример #17
0
 /**
  * Stores the filter text associated with a FILTER_CONTACTS_ACTION intent. This is so child
  * activities can check if they are supposed to display a filter.
  *
  * @param intent The intent received in {@link #onNewIntent(Intent)}
  */
 private void setupFilterText(Intent intent) {
   // If the intent was relaunched from history, don't apply the filter text.
   if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) {
     return;
   }
   String filter = intent.getStringExtra(UI.FILTER_TEXT_EXTRA_KEY);
   if (filter != null && filter.length() > 0) {
     mFilterText = filter;
   }
 }
Пример #18
0
  @Test
  public void getStartActivityIntent_withApplicationContext_shouldReturnIntentWithNewTaskFlag()
      throws Exception {
    Context context = new Activity().getApplicationContext();

    final Intent intent = Intents.getStartActivityIntent(context, MoPubBrowser.class, null);

    assertThat(intent.getComponent().getClassName()).isEqualTo(MoPubBrowser.class.getName());
    assertThat(Utils.bitMaskContainsFlag(intent.getFlags(), FLAG_ACTIVITY_NEW_TASK)).isTrue();
    assertThat(intent.getExtras()).isNull();
  }
Пример #19
0
  @Test
  public void getStartActivityIntent_withBundle_shouldReturnIntentWithExtras() throws Exception {
    Context context = new Activity();
    Bundle bundle = new Bundle();
    bundle.putString("arbitrary key", "even more arbitrary value");

    final Intent intent = Intents.getStartActivityIntent(context, MoPubBrowser.class, bundle);

    assertThat(intent.getComponent().getClassName()).isEqualTo(MoPubBrowser.class.getName());
    assertThat(Utils.bitMaskContainsFlag(intent.getFlags(), FLAG_ACTIVITY_NEW_TASK)).isFalse();
    assertThat(intent.getExtras()).isEqualTo(bundle);
  }
  @Override
  public void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    // If it is not launched from history, then reset to top-level
    if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) {
      if (mFirstHeader != null && !onIsHidingHeaders() && onIsMultiPane()) {
        switchToHeaderLocal(mFirstHeader);
      }
      getListView().setSelectionFromTop(0, 0);
    }
  }
Пример #21
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detail_schedule);
    final Intent intent = getIntent();
    intentflag = intent.getFlags();

    editTitle = (EditText) this.findViewById(R.id.edit_title);
    editContent = (EditText) this.findViewById(R.id.edit_content);
    buttonNew = (Button) this.findViewById(R.id.save);
    buttonDel = (Button) this.findViewById(R.id.delete);
    if (intentflag == 1) {
      buttonNew.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              new Thread(new MyThread(1)).start();
              finish();
            }
          });
    } else {
      new Thread(new MyThread(4, intentflag)).start();
      buttonNew.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              new Thread(new MyThread(2)).start();
              finish();
            }
          });
    }
    buttonDel.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            AlertDialog.Builder builder = new AlertDialog.Builder(DetailSchedule.this);
            builder.setTitle("提示");
            builder.setMessage("真的要删除吗?");
            builder.setPositiveButton(
                "确认",
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialogInterface, int i) {
                    new Thread(new MyThread(3, intentflag)).start();
                    finish();
                  }
                });
            builder.setNegativeButton("取消", null);
            builder.create().show();
          }
        });
  }
 /** {@inheritDoc} */
 @Override
 protected void onDestroy() {
   super.onDestroy();
   final Intent intent = new Intent(this.connector.getPackage() + Connector.ACTION_CAPTCHA_SOLVED);
   final String s = ((EditText) this.findViewById(R.id.solved)).getText().toString();
   if (s.length() > 0) {
     Log.d(TAG, "solved: " + s);
     intent.putExtra(Connector.EXTRA_CAPTCHA_SOLVED, s);
   }
   intent.setFlags(intent.getFlags() | Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
   Log.d(TAG, "send broadcast: " + intent.getAction());
   this.sendBroadcast(intent);
 }
Пример #23
0
 public static void setActivity(Intent intent, Context context) {
   Bundle extras = intent.getExtras();
   String str = null;
   if (intent.getAction().matches("CHANGE_ACTVITYINTABLE")) {
     int cos = intent.getFlags();
     str = extras.getString("nr");
     // aktywnosci[cos] = str;
   }
   RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.activity_main);
   remoteViews.setTextViewText(R.id.widget_textview0, str);
   pushWidgetUpdate(context, remoteViews);
   Toast.makeText(context, str, Toast.LENGTH_SHORT).show();
 }
Пример #24
0
  @Override
  protected void onResume() {
    super.onResume();
    Intent intent = getIntent();
    if (intent != null && (intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) {
      Uri uri = intent.getData();
      if (uri != null && uri.toString().startsWith(getCallbackUrl().toString())) {
        String verifier = uri.getQueryParameter("oauth_verifier");

        reqAccessToken(verifier);
      }
    }
  }
Пример #25
0
 @Override
 protected void onNewIntent(Intent intent) {
   super.onNewIntent(intent);
   Timber.d("%s, onNewIntent intent=%s", this, intent);
   if ((Intent.FLAG_ACTIVITY_CLEAR_TOP & intent.getFlags()) != 0) {
     KApplicationImpl.getInstance().closeDb();
     Timber.d("%s, 结束APP... onNewIntent intent=%s", this, intent);
     finish();
   } else {
     Timber.d("%s, 退出帐号... onNewIntent intent=%s", this, intent);
     toHomePage();
   }
 }
  @Test
  public void handleShouldOverrideUrl_smsUrl_clicked_shouldStartActivity() {
    subjectBanner.setClicked(true);
    reset(mockBannerWebView);
    when(mockBannerWebView.getContext()).thenReturn(activity);

    boolean result = subjectBanner.handleShouldOverrideUrl("sms://123456789");

    Intent startedIntent = Robolectric.getShadowApplication().getNextStartedActivity();
    assertThat(startedIntent).isNotNull();
    assertThat(startedIntent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK).isNotEqualTo(0);
    assertThat(startedIntent.getComponent()).isNull();
    assertThat(result).isTrue();
  }
Пример #27
0
  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {

    try {
      FLAGS = intent.getFlags();
    } catch (Exception e) {
      Log.e(TAG, e.toString());
    }

    Log.i(TAG, "FLAGS " + FLAGS);

    // 加载事件信息
    loadEvent();

    return START_STICKY;
  }
 private void fillIntent(@Nullable Intent intent, @NonNull TextView textView) {
   if (intent == null) {
     textView.setText(Printer.EMPTY);
     return;
   }
   Truss truss = new Truss();
   Printer.append(truss, "action", intent.getAction());
   Printer.append(truss, "categories", intent.getCategories());
   Printer.append(truss, "type", intent.getType());
   Printer.append(truss, "flags", Flags.decode(intent.getFlags()));
   Printer.append(truss, "package", intent.getPackage());
   Printer.append(truss, "component", intent.getComponent());
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
     Printer.append(truss, "referrer", getReferrer());
   }
   textView.setText(truss.build());
 }
  @Test
  public void handleOpen_withHttpApplicationUrl_shouldStartMoPubBrowser() {
    String applicationUrl = "https://www.mopub.com/";

    subject.handleOpen(applicationUrl);

    Robolectric.getBackgroundThreadScheduler().advanceBy(0);
    Intent startedIntent = ShadowApplication.getInstance().getNextStartedActivity();
    assertThat(startedIntent).isNotNull();
    // Since we are not using an Activity context, we should have FLAG_ACTIVITY_NEW_TASK
    assertThat(Utils.bitMaskContainsFlag(startedIntent.getFlags(), Intent.FLAG_ACTIVITY_NEW_TASK))
        .isTrue();
    assertThat(startedIntent.getComponent().getClassName())
        .isEqualTo("com.mopub.common.MoPubBrowser");

    verify(mockMraidListener).onOpen();
  }
  @Test
  public void handleOpen_withApplicationUrl_shouldStartNewIntent() {
    String applicationUrl = "amzn://blah";
    RuntimeEnvironment.getRobolectricPackageManager()
        .addResolveInfoForIntent(
            new Intent(Intent.ACTION_VIEW, Uri.parse(applicationUrl)), new ResolveInfo());

    subject.handleOpen(applicationUrl);

    Intent startedIntent = ShadowApplication.getInstance().getNextStartedActivity();
    assertThat(startedIntent).isNotNull();
    // Since we are not using an Activity context, we should have FLAG_ACTIVITY_NEW_TASK
    assertThat(Utils.bitMaskContainsFlag(startedIntent.getFlags(), Intent.FLAG_ACTIVITY_NEW_TASK))
        .isTrue();
    assertThat(startedIntent.getComponent()).isNull();

    verify(mockMraidListener).onOpen();
  }