示例#1
1
  public void logIntent(String tag, String msg, Intent intent, int logLevel, boolean logExtras) {
    StringBuilder sb = new StringBuilder();

    if (msg != null) {
      sb.append(msg);
      sb.append(intent.toString());
    } else {
      sb.append("LOG Intent: ");
      sb.append(intent.toString());
    }

    if (intent.getAction() != null) {
      sb.append(intent.getAction());
      sb.append(" ");
    }

    if (intent.getDataString() != null) {
      sb.append(intent.getDataString());
      sb.append(" ");
    }

    if (logExtras) {
      Bundle extras = intent.getExtras();
      if (extras != null) {
        for (String key : extras.keySet()) {
          String extra = String.valueOf(extras.get(key));
          sb.append(String.format("EXTRA [\"%s\"]: %s ", key, extra));
        }
      }
    }

    log(tag, sb.toString(), logLevel);
  }
示例#2
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());
        }
      }
    }
  }
示例#3
1
  @UnityCallable
  public static void GetAppLink(String paramsStr) {
    Log.v(TAG, "GetAppLink(" + paramsStr + ")");
    final UnityParams unityParams = UnityParams.parse(paramsStr);
    UnityMessage unityMessage =
        UnityMessage.createWithCallbackFromParams("OnGetAppLinkComplete", unityParams);

    // If we don't have an intent return
    if (intent == null) {
      unityMessage.put("did_complete", true);
      unityMessage.send();
      return;
    }

    // Check to see if we have any app link data on the intent
    AppLinkData appLinkData = AppLinkData.createFromAlApplinkData(intent);
    if (appLinkData != null) {
      // We have an app link
      FB.addAppLinkToMessage(unityMessage, appLinkData);
      unityMessage.put("url", intent.getDataString());
    } else if (intent.getData() != null) {
      // We have a deep link
      unityMessage.put("url", intent.getDataString());
    } else {
      // No deep link or app link was provided when activity was started
      unityMessage.put("did_complete", true);
    }

    unityMessage.send();
  }
示例#4
1
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (data != null
        && requestCode == IMPORT_CONTACT
        && builder instanceof CreateMeetingViewBuilder) {
      Log.d(TAG, "Contact Imported");
      final String contactName = data.getStringExtra("ContactName");
      if (contactName != null) {
        LinearLayout contactsLinearLayout = (LinearLayout) findViewById(R.id.invitesll);
        LayoutInflater inflater = LayoutInflater.from(this);
        inflater.inflate(R.layout.contacttvl, contactsLinearLayout);
        ((CreateMeetingViewBuilder) builder).setInviteName(contactName);
      }
    } else if (data != null) {
      filePathName = "";
      if (requestCode == PICTURE_REQUEST) {
        if (resultCode == Activity.RESULT_OK) {
          Log.d(TAG, data.getDataString());
          Uri selectedImage = data.getData();
          String[] filePathColumn = {MediaStore.Images.Media.DATA};

          Cursor cursor =
              getContentResolver().query(selectedImage, filePathColumn, null, null, null);
          cursor.moveToFirst();

          int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
          filePathName = cursor.getString(columnIndex);
          cursor.close();
        }
      } else if (requestCode == GALLERY_REQUEST) {
        if (resultCode == Activity.RESULT_OK) {
          Log.d(TAG, data.getDataString());
          Uri selectedImage = data.getData();
          String[] filePathColumn = {MediaStore.Images.Media.DATA};

          Cursor cursor =
              getContentResolver().query(selectedImage, filePathColumn, null, null, null);
          cursor.moveToFirst();

          int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
          filePathName = cursor.getString(columnIndex);
          cursor.close();
        }
      }

      if (filePathName != null && filePathName.trim().length() > 0) {
        hasAttachment = true;
        Toast.makeText(this, "Filed", Toast.LENGTH_LONG).show();
        Log.d(TAG, "File path: " + filePathName);
      } else {
        Log.e(TAG, "Something wrong in saving the picture: " + filePathName);
      }
    }
  }
示例#5
1
  public LevelImportMode(ModeController modeController, GameResources gameResources, Intent intent)
      throws IOException {
    super(modeController, gameResources);

    camera.center.set(0, 0, 0);
    camera.eye.set(0, 15, -15f);

    if ("content".equals(intent.getScheme())) {
      InputStream attachment = context.getContentResolver().openInputStream(intent.getData());
      level = Level.loadFromFile(attachment, gameResources);
      attachment.close();
    } else {
      File importFile = new File(intent.getDataString());
      levelFileName = importFile.getName();
      if (!levelFileName.endsWith(".bclevel")) levelFileName = ".bclevel";

      InputStream attachment = context.getContentResolver().openInputStream(intent.getData());
      level = Level.loadFromFile(attachment, gameResources);
      attachment.close();
    }

    if (level != null) {
      state = new GameState(level);
    }
  }
示例#6
1
文件: Navit.java 项目: zoff99/navit
	@Override
	public void onResume()
	{
		super.onResume();
		Log.e("Navit", "OnResume");
		//InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
		// DEBUG
		// intent_data = "google.navigation:q=Wien Burggasse 27";
		// intent_data = "google.navigation:q=48.25676,16.643";
		// intent_data = "google.navigation:ll=48.25676,16.643&q=blabla-strasse";
		// intent_data = "google.navigation:ll=48.25676,16.643";
		if (startup_intent != null)
		{
			if (System.currentTimeMillis() <= Navit.startup_intent_timestamp + 4000L)
			{
				Log.e("Navit", "**2**A " + startup_intent.getAction());
				Log.e("Navit", "**2**D " + startup_intent.getDataString());
				String navi_scheme = startup_intent.getScheme();
				if ( navi_scheme != null && navi_scheme.equals("google.navigation")) {
					parseNavigationURI(startup_intent.getData().getSchemeSpecificPart());
				}
			}
			else {
				Log.e("Navit", "timestamp for navigate_to expired! not using data");
			}
		}
	}
示例#7
0
  @Override
  public void onReceive(Context context, Intent intent) {

    if (intent.getAction().equals(Intent.ACTION_PACKAGE_REPLACED)) {
      ApplicationInfo app = new ApplicationInfo();
      Intent LaunchIntent =
          context.getPackageManager().getLaunchIntentForPackage("com.wq.androidtest");
      context.startActivity(LaunchIntent);
    }
    ToastUtil.showToast(context, "x504 : " + intent.getAction() + " " + intent.getDataString());
    System.out.println("x504:" + intent.getAction() + " :" + intent.getDataString() + "包名的程序");
  }
示例#8
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   Intent intent = getIntent();
   String data = intent.getDataString();
   System.out.println(data);
 }
  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());
  }
    @Override
    public List<ComponentName> queryIntentActivities(Intent intent) {
      List<ComponentName> list = new ArrayList<ComponentName>();
      if (intent.getDataString().startsWith("http://m.youtube.com")
          || intent.getDataString().startsWith("http://youtube.com")) {
        list.add(new ComponentName("youtube", "youtube"));
      } else if (intent.getDataString().startsWith(PLUS_STREAM_URL)) {
        list.add(new ComponentName("plus", "plus"));
      } else if (intent.getDataString().startsWith(CALENDAR_URL)) {
        list.add(new ComponentName("calendar", "calendar"));
      } else {
        list.add(new ComponentName("foo", "foo"));
      }

      return list;
    }
示例#11
0
 /** {@inheritDoc} */
 @Override
 public final void onClick(final View v) {
   switch (v.getId()) {
     case R.id.add:
       Preferences.setDefaultPlan(this, false);
       Intent intent = new Intent(this, RuleEdit.class);
       this.startActivity(intent);
       break;
     case R.id.ok:
       Preferences.setDefaultPlan(this, false);
       this.finish();
       break;
     case R.id.import_default:
       intent = new Intent(Intent.ACTION_VIEW, Uri.parse(this.getString(R.string.url_rulesets)));
       try {
         this.startActivity(intent);
       } catch (ActivityNotFoundException e) {
         Log.e(TAG, "no activity to load url", e);
         Toast.makeText(
                 this, "no activity to load url: " + intent.getDataString(), Toast.LENGTH_LONG)
             .show();
       }
       break;
     default:
       break;
   }
 }
示例#12
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    try {
      if ((requestCode == 0) && (resultCode == RESULT_OK)) {
        // Login

        String res = data.getDataString();
        if (res.equals("register")) {
          importFromProfile();

        } else if (!res.equals("login")) {
          this.finish();
          return;
        }

        enableNfc();

        doStuffOnStart();

        showDataInMyContact(fragment_mycontact.getView());
        showDataInMyFriends(fragment_friends.getView());

        /*new SyncAndroidContacts(getApplicationContext())
        .askForProfileContentObserver();*/

      } else if ((requestCode == 2) && (resultCode == RESULT_OK)) {
        showDataInMyContact(fragment_mycontact.getView());
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Tjek om vi er blevet startet med et Intent med en URL, f.eks. som
    // new Intent(Intent.ACTION_VIEW, Uri.parse("http://javabog.dk/OOP/kapitel3.jsp"));

    Intent i = getIntent();
    String urlFraIntent = i.getDataString();

    if (urlFraIntent == null) {
      TextView tv = new TextView(this);
      tv.setText(
          "Dette eksempel viser hvordan man fanger et browserintent.\n"
              + "Gå ind på http://javabog.dk og vælg et kapitel fra grundbogen, "
              + "f.eks http://javabog.dk/OOP/kapitel3.jsp ");
      Linkify.addLinks(tv, Linkify.ALL);
      setContentView(tv);
    } else {
      // Ok, der var en URL med i intentet
      Toast.makeText(this, "AndroidElementer viser\n" + urlFraIntent, Toast.LENGTH_LONG).show();
      Toast.makeText(this, "Intent var\n" + i, Toast.LENGTH_LONG).show();

      WebView webView = new WebView(this);
      webView.loadUrl(urlFraIntent);

      setContentView(webView);
    }
  }
  @Test
  public void handleOpen_withMoPubNativeBrowserUrl_shouldOpenExternalBrowser() {
    subject.handleOpen("mopubnativebrowser://navigate?url=https%3A%2F%2Fwww.example.com");

    Intent intent = ShadowApplication.getInstance().getNextStartedActivity();
    assertThat(intent.getDataString()).isEqualTo("https://www.example.com");
    assertThat(intent.getAction()).isEqualTo(Intent.ACTION_VIEW);
  }
 @Override
 public boolean isSpecializedHandlerAvailable(Intent intent) {
   String data = intent.getDataString();
   return (data.startsWith("http://youtube.com")
       || data.startsWith("http://m.youtube.com")
       || data.startsWith(CALENDAR_URL)
       || data.startsWith("wtai://wp/"));
 }
 /**
  * {@inheritDoc}
  *
  * @see android.app.Activity#onActivityResult(int, int, android.content.Intent)
  */
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (resultCode == RESULT_OK) {
     if (requestCode == ApplicationConstants.ACTIVITY_RETURN_CHOOSE_FILE) {
       fileUril.setText(data.getDataString());
     }
   }
 }
示例#17
0
 @Override
 public boolean onUnbind(Intent intent) {
   String chatPartner = intent.getDataString();
   if ((chatPartner != null)) {
     mIsBoundTo.remove(chatPartner);
   }
   return true;
 }
示例#18
0
 @Override
 public void onRebind(Intent intent) {
   super.onRebind(intent);
   String chatPartner = intent.getDataString();
   if ((chatPartner != null)) {
     mIsBoundTo.add(chatPartner);
     resetNotificationCounter(chatPartner);
   }
 }
示例#19
0
 /**
  * 处理传进来的intent
  *
  * @author 火蚁 2015-1-28 下午3:48:44
  * @return void
  * @param intent
  */
 private void handleIntent(Intent intent) {
   if (intent == null) return;
   String action = intent.getAction();
   if (action != null && action.equals(Intent.ACTION_VIEW)) {
     UIHelper.showUrlRedirect(this, intent.getDataString());
   } else if (intent.getBooleanExtra("NOTICE", false)) {
     notifitcationBarClick(intent);
   }
 }
 @Override
 public void onReceive(Context context, Intent intent) {
   Log.d("BroadcastReceiver", "triggered");
   new SendActiveHandler(
           intent.getBooleanExtra(Constants.EXTRA_SET_ACTIVE, false),
           intent.getDataString(),
           context)
       .execute();
 }
示例#21
0
 private void setContactFromUri() {
   Intent i = getIntent();
   mWithJabberID = i.getDataString().toLowerCase();
   if (i.hasExtra(INTENT_EXTRA_USERNAME)) {
     mUserScreenName = i.getExtras().getString(INTENT_EXTRA_USERNAME);
   } else {
     mUserScreenName = mWithJabberID;
   }
 }
示例#22
0
  public boolean loadIntent(Intent intent) {
    String action = intent.getAction();

    if (Intent.ACTION_VIEW.equals(action)) {
      loadUrl(intent.getDataString());
      return true;
    }

    return false;
  }
 @Override
 public List<ResolveInfo> queryIntentActivities(Intent intent, int flags) {
   List<ResolveInfo> resolves = new ArrayList<ResolveInfo>();
   if (intent.getDataString().startsWith("http://m.youtube.com")
       || intent.getDataString().startsWith("http://youtube.com")) {
     ResolveInfo youTubeApp = new ResolveInfo();
     youTubeApp.activityInfo = new ActivityInfo();
     youTubeApp.activityInfo.packageName = "youtube";
     youTubeApp.activityInfo.name = "youtube";
     resolves.add(youTubeApp);
   } else {
     ResolveInfo fooApp = new ResolveInfo();
     fooApp.activityInfo = new ActivityInfo();
     fooApp.activityInfo.packageName = "foo";
     fooApp.activityInfo.name = "foo";
     resolves.add(fooApp);
   }
   return resolves;
 }
 /** Returns the URI from the activity. */
 @SimpleProperty(category = PropertyCategory.BEHAVIOR)
 public String ResultUri() {
   if (resultIntent != null) {
     String resultUri = resultIntent.getDataString();
     if (resultUri != null) {
       return resultUri;
     }
   }
   return "";
 }
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (!waitingForResult) return;
    waitingForResult = false;

    if (resultCode != Activity.RESULT_OK || data == null) return;

    String task = data.getDataString();
    if (task != null) add(task);
  }
示例#26
0
  public boolean loadIntent(Intent intent) {
    String action = intent.getAction();

    if (Intent.ACTION_RUN.equals(action)) {
      mView.getEngine().runFromBundle(intent.getDataString());
      String route = intent.getStringExtra("route");
      if (route != null) mView.getEngine().pushRoute(route);
      return true;
    }

    return false;
  }
示例#27
0
  @Override
  public IBinder onBind(Intent intent) {
    super.onBind(intent);
    String chatPartner = intent.getDataString();
    if ((chatPartner != null)) {
      resetNotificationCounter(chatPartner);
      mIsBoundTo.add(chatPartner);
      return mServiceChatConnection;
    }

    return mService2RosterConnection;
  }
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (resultCode == RESULT_CANCELED || data == null) return;
   switch (requestCode) {
     case REQUEST_CODE_SELECT_PIC:
       Log.i(LOG_TAG, " select file :" + data.getDataString());
       uploadTask = new FileUploadTask(this, this, data.getData());
       break;
     default:;
   }
   super.onActivityResult(requestCode, resultCode, data);
 }
 /**
  * Returns true if the intent is a valid launch intent for a shortcut. This is used to identify
  * shortcuts which are different from the ones exposed by the applications' manifest file.
  *
  * <p>When DISABLE_ALL_APPS is true, shortcuts exposed via the app's manifest should never be
  * duplicated or removed(unless the app is un-installed).
  *
  * @param launchIntent The intent that will be launched when the shortcut is clicked.
  */
 static boolean isValidShortcutLaunchIntent(Intent launchIntent) {
   if (launchIntent != null
       && Intent.ACTION_MAIN.equals(launchIntent.getAction())
       && launchIntent.getComponent() != null
       && launchIntent.getCategories() != null
       && launchIntent.getCategories().size() == 1
       && launchIntent.hasCategory(Intent.CATEGORY_LAUNCHER)
       && launchIntent.getExtras() == null
       && TextUtils.isEmpty(launchIntent.getDataString())) {
     return false;
   }
   return true;
 }
  /** This Creates the activity, the Viewpager, and its adapter. */
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Extract intent's data.
    Intent intent = getIntent();

    Log.v(TAG, "2" + intent);
    Log.v(TAG, "2" + intent.getDataString());

    // If the intent exists and contains the filepath, extract its
    // data
    if (intent != null && intent.getDataString() != null) {
      mCurrentImage = intent.getIntExtra(CURRENT_IMAGE_POSITION, 0);
      mFilePath = intent.getDataString();
    }
    Log.v(TAG, "mFilePath" + mFilePath);

    // Set the content view.
    setContentView(R.layout.image_detail_swipe_activity);

    // Find the screen's width
    DisplayMetrics displaymetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    mWidth = displaymetrics.widthPixels;

    // Initialize the pager adapter.
    File dirFile = new File(mFilePath);
    mImagePagerAdapter = new ImagePagerAdapter(getFragmentManager(), dirFile.listFiles());

    // Initialize the ViewPager using the pager adapter
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mImagePagerAdapter);
    mViewPager.setCurrentItem(mCurrentImage);
    Log.v(TAG, "first image #: " + mCurrentImage);

    // Initialize the ImageLoader
    mLoader = new ImageLoader(getResources().getDrawable(R.drawable.ic_download));
  }