List of usage examples for android.content IntentFilter IntentFilter
public IntentFilter(Parcel source)
From source file:org.wso2.app.catalog.api.ApplicationManager.java
/** * Installs an application to the device. * * @param url - APK Url should be passed in as a String. *//*from www.j a v a 2 s . c o m*/ public void installApp(String url) { if (isPackageInstalled(Constants.AGENT_PACKAGE_NAME)) { CommonUtils.callAgentApp(context, Constants.Operation.INSTALL_APPLICATION, url, null); } else if (isDownloadManagerAvailable(context)) { IntentFilter filter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE); context.registerReceiver(downloadReceiver, filter); downloadViaDownloadManager(url, downloadedAppName); } else { AppUpdater updater = new AppUpdater(); updater.execute(url); } }
From source file:dk.ciid.android.infobooth.activities.IntroductionActivity.java
@Override public void onCreate(Bundle savedInstanceState) { /* Variables received through Intent */ Intent openActivity = getIntent(); // this is just for example purpose isInDebugMode = openActivity.getBooleanExtra("isInDebugMode", true); // should the app send a welcome sms after subscribing? voice1 = openActivity.getStringExtra("voice1"); // path to voice file 1 voice2 = openActivity.getStringExtra("voice2"); // path to voice file 2 voice3 = openActivity.getStringExtra("voice3"); // path to voice file 3 voice4 = openActivity.getStringExtra("voice4"); // path to voice file 4 voice5 = openActivity.getStringExtra("voice5"); // path to voice file 5 voice6 = openActivity.getStringExtra("voice6"); // path to voice file 6 /* Variables received through Intent */ super.onCreate(savedInstanceState); /* ARDUINO COMMUNICATION STUFF ********************************************/ // a reference to the USB system service is obtained so that you can call its methods later on mUsbManager = UsbManager.getInstance(this); mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0); IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION); filter.addAction(UsbManager.ACTION_USB_ACCESSORY_DETACHED); registerReceiver(mUsbReceiver, filter); if (getLastNonConfigurationInstance() != null) { mAccessory = (UsbAccessory) getLastNonConfigurationInstance(); openAccessory(mAccessory);//from w w w . j av a 2 s . com } /* ARDUINO COMMUNICATION STUFF ********************************************/ gestureScanner = new GestureDetector(this); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_introduction); // Set up sound playback initMediaPlayer(); runOnUiThread(new Runnable() { public void run() { if (isInDebugMode) Toast.makeText(getApplicationContext(), "Debug mode is ON", Toast.LENGTH_SHORT).show(); } }); }
From source file:bolts.AppLinkTest.java
public void testAppLinkNavInEventBroadcast() throws Exception { Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com")); Bundle appLinkData = new Bundle(); appLinkData.putString("target_url", "http://www.example2.com"); Bundle appLinkRefererData = new Bundle(); appLinkRefererData.putString("url", "referer://"); appLinkRefererData.putString("app_name", "Referrer App"); appLinkRefererData.putString("package", "com.bolts.referrer"); appLinkData.putBundle("referer_app_link", appLinkRefererData); Bundle applinkExtras = new Bundle(); applinkExtras.putString("token", "a_token"); appLinkData.putBundle("extras", applinkExtras); i.putExtra("al_applink_data", appLinkData); final CountDownLatch lock = new CountDownLatch(1); final String[] receivedStrings = new String[7]; LocalBroadcastManager manager = LocalBroadcastManager.getInstance(getInstrumentation().getTargetContext()); manager.registerReceiver(new BroadcastReceiver() { @Override/* w w w . ja v a 2s . co m*/ public void onReceive(Context context, Intent intent) { String eventName = intent.getStringExtra("event_name"); Bundle eventArgs = intent.getBundleExtra("event_args"); receivedStrings[0] = eventName; receivedStrings[1] = eventArgs.getString("targetURL"); receivedStrings[2] = eventArgs.getString("inputURL"); receivedStrings[3] = eventArgs.getString("refererURL"); receivedStrings[4] = eventArgs.getString("refererAppName"); receivedStrings[5] = eventArgs.getString("extras/token"); receivedStrings[6] = eventArgs.getString("sourceApplication"); lock.countDown(); } }, new IntentFilter("com.parse.bolts.measurement_event")); Uri targetUrl = AppLinks.getTargetUrlFromInboundIntent(getInstrumentation().getTargetContext(), i); lock.await(2000, TimeUnit.MILLISECONDS); assertEquals("al_nav_in", receivedStrings[0]); assertEquals("http://www.example2.com", receivedStrings[1]); assertEquals("http://www.example.com", receivedStrings[2]); assertEquals("referer://", receivedStrings[3]); assertEquals("Referrer App", receivedStrings[4]); assertEquals("a_token", receivedStrings[5]); assertEquals("com.bolts.referrer", receivedStrings[6]); }
From source file:com.feedhenry.sdk.api.FHAuthRequest.java
private void startAuthIntent(final JSONObject pJsonRes, final FHActCallback pCallback) throws Exception { String url = pJsonRes.getString("url"); FHLog.v(LOG_TAG, "Got oAuth url back, url = " + url + ". Open it in new intent."); Bundle data = new Bundle(); data.putString("url", url); data.putString("title", "Login"); Intent i = new Intent(mPresentingActivity, FHOAuthIntent.class); mReceiver = new OAuthURLRedirectReceiver(pCallback); IntentFilter filter = new IntentFilter(FHOAuthWebView.BROADCAST_ACTION_FILTER); mPresentingActivity.registerReceiver(mReceiver, filter); i.putExtra("settings", data); mPresentingActivity.startActivity(i); }
From source file:dk.ciid.android.infobooth.activities.SubscriptionFinalActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { /* Variables received through Intent */ Intent openActivity = getIntent(); // this is just for example purpose isInDebugMode = openActivity.getBooleanExtra("isInDebugMode", true); // should the app send a welcome sms after subscribing? phoneNum = openActivity.getStringExtra("phoneNum"); // get the phonenumber submitted in the last activity selectedService = openActivity.getIntExtra("selectedService", 1); // array position of selected service in last activity serviceIdItems = openActivity.getStringArrayListExtra("serviceIdItems"); // arraylist of service id's (in database) serviceNameItems = openActivity.getStringArrayListExtra("serviceNameItems"); // arraylist of service names serviceDescItems = openActivity.getStringArrayListExtra("serviceDescItems"); // arraylist of service descriptions voice1 = openActivity.getStringExtra("voice1"); // path to voice file 1 voice2 = openActivity.getStringExtra("voice2"); // path to voice file 2 voice3 = openActivity.getStringExtra("voice3"); // path to voice file 3 voice4 = openActivity.getStringExtra("voice4"); // path to voice file 4 voice5 = openActivity.getStringExtra("voice5"); // path to voice file 5 voice6 = openActivity.getStringExtra("voice6"); // path to voice file 6 /* Variables received through Intent */ // TODO Auto-generated method stub super.onCreate(savedInstanceState); /* ARDUINO COMMUNICATION STUFF ********************************************/ // a reference to the USB system service is obtained so that you can call its methods later on mUsbManager = UsbManager.getInstance(this); mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0); IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION); filter.addAction(UsbManager.ACTION_USB_ACCESSORY_DETACHED); registerReceiver(mUsbReceiver, filter); if (getLastNonConfigurationInstance() != null) { mAccessory = (UsbAccessory) getLastNonConfigurationInstance(); openAccessory(mAccessory);/*from w w w . j a v a 2s . c om*/ } /* ARDUINO COMMUNICATION STUFF ********************************************/ gestureScanner = new GestureDetector(this); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_subscription_final); if (!isInDebugMode) { try { //SmsManager smsManager = SmsManager.getDefault(); //smsManager.sendTextMessage(phoneNumber, null, SMSMessage, null, null); Toast.makeText(getApplicationContext(), "Thanks for subscribing!", Toast.LENGTH_SHORT).show(); } catch (Exception e) { Toast.makeText(getApplicationContext(), "SMS failed, please try again later!", Toast.LENGTH_SHORT) .show(); e.printStackTrace(); } } else { Toast.makeText(getApplicationContext(), "Debug mode - no SMS sent to save money :)", Toast.LENGTH_SHORT) .show(); } // Set up sound playback initMediaPlayer(); }
From source file:eu.nubomedia.nubomedia_kurento_health_communicator_android.kc_and_communicator.util.FileUtils.java
public static void DownloadFromUrl(final String media, final String messageId, final Context ctx, final ImageView container, final Object object, final String timelineId, final String localId, final Long fileSize) { new AsyncTask<Void, Void, Boolean>() { private boolean retry = true; private Bitmap imageDownloaded; private BroadcastReceiver mDownloadCancelReceiver; private HttpGet job; private AccountManager am; private Account account; private String authToken; @Override/*from w ww .j a v a2s . c om*/ protected void onPreExecute() { IntentFilter downloadFilter = new IntentFilter(ConstantKeys.BROADCAST_CANCEL_PROCESS); mDownloadCancelReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String localIdToClose = (String) intent.getExtras().get(ConstantKeys.LOCALID); if (localId.equals(localIdToClose)) { try { job.abort(); } catch (Exception e) { log.debug("The process was canceled"); } cancel(false); } } }; // registering our receiver ctx.getApplicationContext().registerReceiver(mDownloadCancelReceiver, downloadFilter); } @Override protected void onCancelled() { File file1 = new File(FileUtils.getDir(), localId + ConstantKeys.EXTENSION_JPG); File file2 = new File(FileUtils.getDir(), localId + ConstantKeys.EXTENSION_3GP); if (file1.exists()) { file1.delete(); } if (file2.exists()) { file2.delete(); } file1 = null; file2 = null; System.gc(); try { ctx.getApplicationContext().unregisterReceiver(mDownloadCancelReceiver); } catch (Exception e) { log.debug("Receriver unregister from another code"); } for (int i = 0; i < AppUtils.getlistOfDownload().size(); i++) { if (AppUtils.getlistOfDownload().get(i).equals(localId)) { AppUtils.getlistOfDownload().remove(i); } } DataBasesAccess.getInstance(ctx.getApplicationContext()).MessagesDataBaseWriteTotal(localId, 100); Intent intent = new Intent(); intent.setAction(ConstantKeys.BROADCAST_DIALOG_DOWNLOAD_FINISH); intent.putExtra(ConstantKeys.LOCALID, localId); ctx.sendBroadcast(intent); if (object != null) { ((ProgressDialog) object).dismiss(); } } @Override protected Boolean doInBackground(Void... params) { try { File file1 = new File(FileUtils.getDir(), localId + ConstantKeys.EXTENSION_JPG); File file2 = new File(FileUtils.getDir(), localId + ConstantKeys.EXTENSION_3GP); // firt we are goint to search the local files if ((!file1.exists()) && (!file2.exists())) { account = AccountUtils.getAccount(ctx.getApplicationContext(), false); am = (AccountManager) ctx.getSystemService(Context.ACCOUNT_SERVICE); authToken = ConstantKeys.STRING_DEFAULT; authToken = am.blockingGetAuthToken(account, ctx.getString(R.string.account_type), true); MessagingClientService messageService = new MessagingClientService( ctx.getApplicationContext()); URL urlObj = new URL(Preferences.getServerProtocol(ctx), Preferences.getServerAddress(ctx), Preferences.getServerPort(ctx), ctx.getString(R.string.url_get_content)); String url = ConstantKeys.STRING_DEFAULT; url = Uri.parse(urlObj.toString()).buildUpon().build().toString() + timelineId + "/" + messageId + "/" + "content"; job = new HttpGet(url); // first, get free space FreeUpSpace(ctx, fileSize); messageService.getContent(authToken, media, messageId, timelineId, localId, false, false, fileSize, job); } if (file1.exists()) { imageDownloaded = decodeSampledBitmapFromPath(file1.getAbsolutePath(), 200, 200); } else if (file2.exists()) { imageDownloaded = ThumbnailUtils.createVideoThumbnail(file2.getAbsolutePath(), MediaStore.Images.Thumbnails.MINI_KIND); } if (imageDownloaded == null) { return false; } return true; } catch (Exception e) { deleteFiles(); return false; } } @Override protected void onPostExecute(Boolean result) { // We have the media try { ctx.getApplicationContext().unregisterReceiver(mDownloadCancelReceiver); } catch (Exception e) { log.debug("Receiver was closed on cancel"); } if (!(localId.contains(ConstantKeys.AVATAR))) { for (int i = 0; i < AppUtils.getlistOfDownload().size(); i++) { if (AppUtils.getlistOfDownload().get(i).equals(localId)) { AppUtils.getlistOfDownload().remove(i); } } DataBasesAccess.getInstance(ctx.getApplicationContext()).MessagesDataBaseWriteTotal(localId, 100); Intent intent = new Intent(); intent.setAction(ConstantKeys.BROADCAST_DIALOG_DOWNLOAD_FINISH); intent.putExtra(ConstantKeys.LOCALID, localId); ctx.sendBroadcast(intent); } if (object != null) { ((ProgressDialog) object).dismiss(); } // Now the only container could be the avatar in edit screen if (container != null) { if (imageDownloaded != null) { container.setImageBitmap(imageDownloaded); } else { deleteFiles(); imageDownloaded = decodeSampledBitmapFromResource(ctx.getResources(), R.drawable.ic_error_loading, 200, 200); container.setImageBitmap(imageDownloaded); Toast.makeText(ctx.getApplicationContext(), ctx.getApplicationContext().getText(R.string.donwload_fail), Toast.LENGTH_SHORT) .show(); } } else { showMedia(localId, ctx, (ProgressDialog) object); } } private void deleteFiles() { File file1 = new File(FileUtils.getDir(), localId + ConstantKeys.EXTENSION_JPG); File file2 = new File(FileUtils.getDir(), localId + ConstantKeys.EXTENSION_3GP); if (file1.exists()) { file1.delete(); } if (file2.exists()) { file2.delete(); } } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:dk.microting.softkeyboard.autoupdateapk.AutoUpdateApk.java
private void setupVariables(Context ctx) { context = ctx;//from w w w .j a va 2s.c o m packageName = context.getPackageName(); preferences = context.getSharedPreferences(packageName + "_" + TAG, Context.MODE_PRIVATE); last_update = preferences.getLong("last_update", 0); NOTIFICATION_ID += crc32(packageName); ApplicationInfo appinfo = context.getApplicationInfo(); if (appinfo.icon != 0) { appIcon = appinfo.icon; } else { Log.w(TAG, "unable to find application icon"); } if (appinfo.labelRes != 0) { appName = context.getString(appinfo.labelRes); } else { Log.w(TAG, "unable to find application label"); } if (new File(appinfo.sourceDir).lastModified() > preferences.getLong(MD5_TIME, 0)) { preferences.edit().putString(MD5_KEY, MD5Hex(appinfo.sourceDir)).commit(); preferences.edit().putLong(MD5_TIME, System.currentTimeMillis()).commit(); String update_file = preferences.getString(UPDATE_FILE, ""); if (update_file.length() > 0) { if (new File(context.getFilesDir().getAbsolutePath() + "/" + update_file).delete()) { preferences.edit().remove(UPDATE_FILE).commit(); } } } raise_notification(); if (haveInternetPermissions()) { context.registerReceiver(connectivity_receiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); } }
From source file:com.ieeton.user.IeetonApplication.java
@Override public void onCreate() { super.onCreate(); Utils.saveIeetonFrom(this); int pid = android.os.Process.myPid(); String processAppName = getAppName(pid); // ?remote serviceif? if (processAppName == null || processAppName.equals("")) { // workaround for baidu location sdk // ?sdk????????application::onCreate // //w ww . j ava 2 s. co m // sdk??? ?pid ?processInfo // processName // application::onCreate service return; } //? // BaiduLocationHelper.startRequestLocation(this, mIeetonLocationListener); SDKInitializer.initialize(this); applicationContext = this; instance = this; // ?SDK,?init() EMChat.getInstance().init(applicationContext); EMChat.getInstance().setDebugMode(false); // Log.d("EMChat Demo", "initialize EMChat SDK"); // debugmodetrue?sdk?log // ?EMChatOptions EMChatOptions options = EMChatManager.getInstance().getChatOptions(); // ??app??true options.setUseRoster(true); // ??????? options.setAcceptInvitationAlways(false); // ???true,?? options.setNotifyBySoundAndVibrate(true); boolean[] onoff = Utils.getMessageNotifySetting(applicationContext); // ????true options.setNoticeBySound(onoff[0]); // ?? true options.setNoticedByVibrate(onoff[1]); // ?? true Settings settings = Utils.getSettings(applicationContext); options.setUseSpeaker(settings.getViaLoundSpeaker()); // notification?intentintent options.setOnNotificationClickListener(new OnNotificationClickListener() { @Override public Intent onNotificationClick(EMMessage message) { // Intent intent = new Intent(applicationContext, ChatActivity.class); // ChatType chatType = message.getChatType(); // if (chatType == ChatType.Chat) { // ??? // intent.putExtra(ChatActivity.EXTRA_USERID, message.getFrom()); // intent.putExtra("chatType", ChatActivity.CHATTYPE_SINGLE); // } else { // ?? // // message.getTo()?id // intent.putExtra("groupId", message.getTo()); // intent.putExtra("chatType", ChatActivity.CHATTYPE_GROUP); // } Intent intent = new Intent(applicationContext, MainActivity.class); return intent; } }); // connectionlistener??? EMChatManager.getInstance().addConnectionListener(new MyConnectionListener()); // ?app??????????? options.setNotifyText(new OnMessageNotifyListener() { @Override public String onNewMessageNotify(EMMessage message) { // ??message????(??qq)demo???? String notify = ""; String passport = message.getFrom(); String nick = NickNameCache.getInstance().get(passport); if (nick != null && !"".equals(nick)) { String formatStr = getResources().getString(R.string.new_incoming_messages); notify = nick + String.format(formatStr, 1); } else { notify = getString(R.string.new_message); } return notify; } @Override public String onLatestMessageNotify(EMMessage message, int fromUsersNum, int messageNum) { String formatStr = getResources().getString(R.string.new_messages); String notify = String.format(formatStr, fromUsersNum, messageNum); return notify; } @Override public String onSetNotificationTitle(EMMessage message) { // return getString(R.string.app_name); } @Override public int onSetSmallIcon(EMMessage arg0) { // TODO Auto-generated method stub return 0; } }); //? IntentFilter callFilter = new IntentFilter( EMChatManager.getInstance().getIncomingVoiceCallBroadcastAction()); registerReceiver(new VoiceCallReceiver(), callFilter); new GetDomainUrlsTask().execute(); }
From source file:com.ccxt.whl.activity.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //?/*from w w w.java2 s . com*/ DemoApplication.currentUserNick = DemoApplication.getInstance().getUsernNickName(); boolean updatenick = EMChatManager.getInstance().updateCurrentUserNick(DemoApplication.currentUserNick); if (!updatenick) { EMLog.e("LoginActivity", "update current user nick fail"); } //? StatService.setAppKey("32f5355664"); StatService.setAppChannel(""); // mCheckUpdateResponse = this; // mPostUpdateChoiceListener = this; // utestUpdate = new UpdateDialog(this, "?", // mPostUpdateChoiceListener); utestUpdate = new UpdateDialog(this, "?"); // StatUpdateAgent.setTestMode(); // ??????????? //StatUpdateAgent.checkUpdate(arg0, arg1, arg2) // StatUpdateAgent.checkUpdate(MainActivity.this, false, // mCheckUpdateResponse); initView(); inviteMessgeDao = new InviteMessgeDao(this); userDao = new UserDao(this); AseoZdpAseo.initTimer(this); zainaFrament = new ZainaFragment(); gushiFrament = new Zaina_gushi_Fragment(); //fragment??? // chatHistoryFragment = new ChatHistoryFragment(); //?fragment chatHistoryFragment = new ChatAllHistoryFragment(); contactListFragment = new ContactlistFragment(); settingFragment = new SettingsFragment(); //fragments = new Fragment[] { chatHistoryFragment, contactListFragment, settingFragment }; fragments = new Fragment[] { zainaFrament, gushiFrament, chatHistoryFragment, contactListFragment, settingFragment }; // fragment /* getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, chatHistoryFragment) .add(R.id.fragment_container, contactListFragment).hide(contactListFragment).show(chatHistoryFragment) .commit();*/ getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, zainaFrament) .add(R.id.fragment_container, contactListFragment).hide(contactListFragment) .show(chatHistoryFragment).commit(); // ?BroadcastReceiver msgReceiver = new NewMessageBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); intentFilter.setPriority(3); registerReceiver(msgReceiver, intentFilter); // ack?BroadcastReceiver IntentFilter ackMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getAckMessageBroadcastAction()); ackMessageIntentFilter.setPriority(3); registerReceiver(ackMessageReceiver, ackMessageIntentFilter); // ?BroadcastReceiver IntentFilter offlineMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getOfflineMessageBroadcastAction()); registerReceiver(offlineMessageReceiver, offlineMessageIntentFilter); // setContactListener??? EMContactManager.getInstance().setContactListener(new MyContactListener()); // ??listener EMChatManager.getInstance().addConnectionListener(new MyConnectionListener()); // ?listener EMGroupManager.getInstance().addGroupChangeListener(new MyGroupChangeListener()); // sdkUI ??receiverlistener, ??broadcast EMChat.getInstance().setAppInited(); /********/ loadcontact(); check_update();// //showFloatingButton(); }
From source file:com.mappn.gfan.ui.HomeTabActivity.java
private void registerReceivers() { IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); registerReceiver(mNetworkReceiver, filter); IntentFilter intentClickFilter = new IntentFilter(Constants.BROADCAST_CLICK_INTENT); registerReceiver(mIntentClickReceiver, intentClickFilter); IntentFilter appFilter = new IntentFilter(); appFilter.addAction(Intent.ACTION_PACKAGE_ADDED); appFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); appFilter.addAction(Intent.ACTION_PACKAGE_CHANGED); appFilter.addDataScheme("package"); registerReceiver(mInstallReceiver, appFilter); IntentFilter updatefilter = new IntentFilter(); updatefilter.addAction(Constants.BROADCAST_FORCE_EXIT); updatefilter.addAction(Constants.BROADCAST_REMIND_LATTER); updatefilter.addAction(Constants.BROADCAST_DOWNLOAD_OPT); updatefilter.addAction(Constants.BROADCAST_DOWNLOAD); registerReceiver(mUpdateReceiver, updatefilter); }