Example usage for android.content IntentFilter IntentFilter

List of usage examples for android.content IntentFilter IntentFilter

Introduction

In this page you can find the example usage for android.content IntentFilter IntentFilter.

Prototype

public IntentFilter(Parcel source) 

Source Link

Usage

From source file:com.oakesville.mythling.MediaActivity.java

private void registerPlaybackReceiver() {
    if (playbackReceiver == null) {
        playbackReceiver = new BroadcastReceiver() {
            public void onReceive(Context context, Intent intent) {
                showStopMenuItem(false);
            }/*from   ww w  .  j  av a2s . com*/
        };
    }
    registerReceiver(playbackReceiver, new IntentFilter(MusicPlaybackService.ACTION_PLAYBACK_STOPPED));
}

From source file:com.ieeton.agency.DemoApplication.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  av  a 2s.c o m*/
        // sdk??? ?pid ?processInfo
        // processName
        // application::onCreate service 
        return;
    }

    //?
    //BaiduLocationHelper.startRequestLocation(this, mIeetonLocationListener);

    //?domain urls
    try {
        GetDomainUrlsTask task = new GetDomainUrlsTask();
        task.execute();
    } catch (RejectedExecutionException e) {
        e.printStackTrace();
    }

    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(
            PreferenceUtils.getInstance(applicationContext).getSettingMsgNotification());
    // ????true
    options.setNoticeBySound(PreferenceUtils.getInstance(applicationContext).getSettingMsgSound());
    // ?? true
    options.setNoticedByVibrate(PreferenceUtils.getInstance(applicationContext).getSettingMsgVibrate());
    // ?? true
    options.setUseSpeaker(PreferenceUtils.getInstance(applicationContext).getSettingMsgSpeaker());
    // 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 = Utils.getNickCache(getApplicationContext(), 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) {
            //return fromUsersNum + "???" + messageNum + "??";
            String formatStr = getResources().getString(R.string.receive_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);

}

From source file:com.lewa.crazychapter11.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    //set to full screen
    // getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,  WindowManager.LayoutParams.FLAG_FULLSCREEN);

    ///set to no title
    // requestWindowFeature(Window.FEATURE_NO_TITLE);
    // acionBar = getSupportActionBar();
    // acionBar = getActionBar();
    // acionBar.hide();

    // Window win = getWindow();
    //          win.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    //          win.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS  | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);  
    //          win.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);  
    // win.setStatusBarColor(Color.TRANSPARENT);  
    // win.setNavigationBarColor(Color.TRANSPARENT);

    /*//* w  ww. jav a  2s . c  om*/
       win.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
       win.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS  | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);  
       win.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN  | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION  | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);  
       win.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);  
       win.setStatusBarColor(Color.TRANSPARENT);  
       win.setNavigationBarColor(Color.TRANSPARENT);
    //*/

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    /* setTheme(R.style.CrazyTheme); */
    AddGameBtn();
    AddNoification();
    LookupContact();
    AddServiceBtn();
    broadcastMain();
    mediaPlayerMain();
    mediaRecordSoundMain();
    cameraMain();
    recordvideoMain();
    queMySql();
    TestFragment();
    justForTest();
    LoadJson();
    AddTestBtn();
    AddUsageStatsBtn();
    AddPeopleProvideBtn();
    getInput();

    ////just for test shutdown broadcast receiver
    IntentFilter mIntentFilter = new IntentFilter("android.intent.action.ACTION_SHUTDOWN");
    mIntentFilter.addAction("com.lewa.alarm.test");
    mIntentFilter.addAction("android.provider.Telephony.SECRET_CODE");
    mIntentFilter.addAction("android.intent.action.SCREEN_ON");
    mIntentFilter.addAction("android.intent.action.SCREEN_OFF");
    mShoutdown = new shutdownReceiver();
    registerReceiver(mShoutdown, mIntentFilter);
    ////test      

    preferences = getSharedPreferences("crazyit", MODE_WORLD_WRITEABLE | MODE_WORLD_READABLE);
    editor = preferences.edit();

    preferencestime = getSharedPreferences("RMS_Shutdown_time", MODE_WORLD_WRITEABLE | MODE_WORLD_READABLE);
    editortime = preferencestime.edit();

    SharedShutdownTimeRead();

    AddSharedPreBtn();

    etNum = (EditText) findViewById(R.id.etNum);

    // //
    int maxLength = 4;

    InputFilter[] fArray = new InputFilter[1];

    fArray[0] = new InputFilter.LengthFilter(maxLength);

    etNum.setFilters(fArray);
    // //

    calThread = new CalThread();
    calThread.start();

    Log.i("algerheMain", "MainActivity onCreate in!!");
    String page = getString(R.string.str_page, "345", "24");
    Log.i("algerheMain", "page=" + page);

    // /just for test here
    ComponentName comp = getIntent().getComponent();
    show_txt = (EditText) findViewById(R.id.show_txt);
    show_txt.setText(
            "??" + comp.getPackageName() + " \n ??" + comp.getClassName());

    ////MD5 check item
    ///1.IMEI
    TelephonyManager TelephonyMgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
    String szImei = TelephonyMgr.getDeviceId();
    String m_szSIMSerialNm = TelephonyMgr.getSimSerialNumber();
    CellLocation m_location = TelephonyMgr.getCellLocation();
    String m_Line1Number = TelephonyMgr.getLine1Number();
    String m_OperatorName = TelephonyMgr.getSimOperatorName();
    Log.i("algerheTelephonyMgr", "szImei=" + szImei);
    Log.i("algerheTelephonyMgr", "m_szSIMSerialNm=" + m_szSIMSerialNm);
    Log.i("algerheTelephonyMgr", "m_location=" + m_location);
    Log.i("algerheTelephonyMgr", "m_Line1Number=" + m_Line1Number);
    Log.i("algerheTelephonyMgr", "m_OperatorName=" + m_OperatorName);

    Log.i("algerheMain01", "szImei=" + szImei);
    Log.i("algerheMain01", "m_szSIMSerialNm=" + m_szSIMSerialNm);

    ///2.Pseudo-Unique ID
    String m_szDevIDShort = "35" + //we make this look like a valid IMEI 
            Build.BOARD.length() % 10 + Build.BRAND.length() % 10 + Build.CPU_ABI.length() % 10
            + Build.DEVICE.length() % 10 + Build.DISPLAY.length() % 10 + Build.HOST.length() % 10
            + Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 + Build.MODEL.length() % 10
            + Build.PRODUCT.length() % 10 + Build.TAGS.length() % 10 + Build.TYPE.length() % 10
            + Build.USER.length() % 10; //13 digits

    Log.i("algerheMain01", "m_szDevIDShort=" + m_szDevIDShort);

    ///3. Android ID
    String m_szAndroidID = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
    Log.i("algerheMain01", "m_szAndroidID=" + m_szAndroidID);

    ///4.WLAN MAC Address string
    WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    String m_szWLANMAC = "unknow_wifi_mac";
    if (wm != null && wm.getConnectionInfo() != null) {
        m_szWLANMAC = wm.getConnectionInfo().getMacAddress();
    }

    Log.i("algerheMain01", "m_szWLANMAC=" + m_szWLANMAC);

    ///5.BT MAC Address string
    BluetoothAdapter m_BluetoothAdapter = null; // Local Bluetooth adapter      
    m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    String m_szBTMAC = m_BluetoothAdapter.getAddress();

    Log.i("algerheMain01", "m_szBTMAC=" + m_szBTMAC);

    ///6.sim serial number .getSimSerialNumber()

    // /

    ///reflect test   
    checkMethod();

    // */
    final Intent alarmIntent = new Intent();
    Log.i("algerheMain00", "isLewaRom=" + isLewaRom(this, alarmIntent));

    handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            if (msg.what == 0x4567) {
                String languageStr = null;
                String countryStr = null;

                Locale[] locList = Locale.getAvailableLocales();

                for (int i = 0; i < locList.length; i++) {
                    languageStr += locList[i].getLanguage();
                    countryStr += locList[i].getCountry();
                }
                // show_txt = (EditText) findViewById(R.id.show_txt);
                show_txt.setText("" + languageStr + " \n " + countryStr);
            } else if (msg.what == 0x2789) {
                Log.i("algerheAlarm", "send alarm message in time=" + System.currentTimeMillis() + "\n action="
                        + alarmIntent.getAction());

                // sendBroadcast(alarmIntent);
            }
        }
    };

    // String strApkPath = intent.getStringExtra("apkPath");
    //         String strCmd = "pm install -r " + strApkPath;
    //         try {
    //             Process install = Runtime.getRuntime().exec(strCmd);
    //             Log.d(TAG, "install = " + install + ", strCmd =" + strCmd);
    //         }catch (Exception ex){
    //             Log.d(TAG, ex.getMessage());
    //         }   
    // */
}

From source file:com.futureplatforms.kirin.extensions.networking.NetworkingBackend.java

private void listenForChangeInNetworkStatus() {
    Log.i(C.TAG, "NetworkingBackend.listenForChangeInNetworkStatus: ");
    mReceiver = new BroadcastReceiver() {

        @Override/*from w ww .  ja v  a2  s.c om*/
        public void onReceive(Context context, Intent intent) {
            if (intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false)) {
                String reason = intent.getStringExtra(ConnectivityManager.EXTRA_REASON);
                if (reason == null || reason.trim().length() == 0) {
                    reason = mContext.getString(R.string.networking_connection_lost);
                }
                cancelAllDownloads(reason);
            }
        }

    };
    mContext.registerReceiver(mReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));

}

From source file:com.autoupdateapk.AutoUpdateApk.java

private void setupVariables(Context ctx) {
    context = ctx;/*from   w  w  w .j a  va  2 s .com*/

    packageName = context.getPackageName();
    preferences = context.getSharedPreferences(packageName + "_" + TAG, Context.MODE_PRIVATE);
    device_id = crc32(Secure.getString(context.getContentResolver(), Secure.ANDROID_ID));
    last_update = preferences.getLong("last_update", 0);
    NOTIFICATION_ID += crc32(packageName);
    // schedule.add(new ScheduleEntry(0,24));

    ApplicationInfo appinfo = context.getApplicationInfo();
    if (appinfo.icon != 0) {
        appIcon = appinfo.icon;
    } else {
        Log_w(TAG, "unable to find application icon");
    }

    //appName = context.getString(appinfo.labelRes); NON!
    appName = (String) context.getPackageManager().getApplicationLabel(appinfo);
    if (appName != null) {
        Log_w(TAG, "application name = " + appName);
    } 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).remove(SILENT_FAILED).commit();
            }
        }
    }

    // hack
    preferences.edit().remove(SILENT_FAILED).commit();

    raise_notification();

    if (haveInternetPermissions()) {
        context.registerReceiver(connectivity_receiver,
                new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
    }
}

From source file:com.polyvi.xface.extension.XMessagingExt.java

/**
 * ??/*w w w.j a va 2  s. c  om*/
 * @param app         app?app??????UI?
 * @param addr        ?
 * @param body        ?
 * @return     ?
 */
private XExtensionResult sendSMS(XIWebContext webContext, String addr, String body) {

    String regularExpression = "[+*#\\d]+";
    if (!addr.matches(regularExpression)) {
        throw new IllegalArgumentException("address must be digit,*,# or +");
    }

    IntentFilter smsSendIntentFilter = new IntentFilter(SMS_SENT);
    genSendSMSBroadreceiver();
    // ??
    getContext().registerReceiver(mSendSMSBroadcastReceiver, smsSendIntentFilter);

    SmsManager manager = SmsManager.getDefault();
    ArrayList<String> textList = manager.divideMessage(body);
    ArrayList<PendingIntent> smsSendPendingIntentList = genSMSPendingIntentList(textList);
    manager.sendMultipartTextMessage(addr, null, textList, smsSendPendingIntentList, null);

    XExtensionResult er = new XExtensionResult(Status.NO_RESULT);
    er.setKeepCallback(true);
    return er;
}

From source file:fr.simon.marquis.secretcodes.ui.MainActivity.java

@Override
protected void onResume() {
    super.onResume();
    ((SecretCodeAdapter) mGridView.getAdapter()).setSelection(mGridView.getCheckedItemPositions());
    registerReceiver(receiver, new IntentFilter(CrawlerService.BROADCAST_INTENT));
    supportInvalidateOptionsMenu();//  w  ww  .j a va  2s  .com
}

From source file:com.paranoid.gerrit.PatchSetViewerFragment.java

@Override
public void onResume() {
    super.onResume();
    LocalBroadcastManager.getInstance(mParent).registerReceiver(mStatusReceiver,
            new IntentFilter(StatusSelected.ACTION));

    // If we cannot get the status, it is likely phone mode.
    if (getStatus() != null) {
        LocalBroadcastManager.getInstance(mParent).registerReceiver(mStatusReceiver,
                new IntentFilter(ChangeLoadingFinished.ACTION));
    }//  ww w  .  jav  a 2  s  .co  m
}

From source file:com.flipzu.flipzu.Player.java

@Override
public void onResume() {
    super.onResume();

    debug.logV(TAG, "onResume()");

    /* track pageview */
    tracker.trackPageView("/" + this.getLocalClassName());

    if (!isOnline()) {
        setLiveVisible(false);/*w w w . j  a  va  2 s  . c o m*/
        if (intent == null)
            intent = new Intent(this, FlipzuPlayerService.class);
        stopService(intent);
    }

    // request player update.
    sendRequestStatus();
    registerReceiver(broadcastReceiver, new IntentFilter(FlipzuPlayerService.INTENT_FILTER));

    if (bcast != null) {
        AsyncFlipInterface.getComments(Integer.parseInt(bcast.getId()), Player.this);
        timerHandler.postDelayed(mTimerTask, 1000);
        if (!bcast.isLive()) {
            SeekBar seekBar = (SeekBar) findViewById(R.id.seekbar);
            seekBar.setVisibility(View.VISIBLE);
            seekBar.setOnSeekBarChangeListener(this);
        }
    }
    comHandler.postDelayed(mUpdateCommentsTask, 10000);
}

From source file:in.rade.armud.armudclient.MainActivity.java

@Override
public void onResume() {
    super.onResume();
    // Within {@code onPause()}, we pause location updates, but leave the
    // connection to GoogleApiClient intact.  Here, we resume receiving
    // location updates if the user has requested them.
    if (!mReceiverRegistered) {
        LocalBroadcastManager.getInstance(this).registerReceiver(mMsgFromWearReceiver,
                new IntentFilter(Globals.COMMAND_PATH));
        mReceiverRegistered = true;//from  www .  j av a2s  .  c  o m
    }
    if (mGoogleApiClient.isConnected() && mRequestingLocationUpdates) {
        startLocationUpdates();
    }

}