當前位置: 首頁>>代碼示例>>Java>>正文


Java IntentFilter類代碼示例

本文整理匯總了Java中android.content.IntentFilter的典型用法代碼示例。如果您正苦於以下問題:Java IntentFilter類的具體用法?Java IntentFilter怎麽用?Java IntentFilter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IntentFilter類屬於android.content包,在下文中一共展示了IntentFilter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreate

import android.content.IntentFilter; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    s = new Setting();
    Language = s.getLang();
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    Language = preferences.getString("l",Language);
    setLanguage(Language);
    setContentView(R.layout.activity_main);
    BottomNavigationView navigation =  findViewById(R.id.navigation);
    navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
    fm=getSupportFragmentManager();
    fm.beginTransaction().add(R.id.content,new BlankFragment()).commit();
    Intent i = new Intent(this,SocketService.class);
    bindService(i,myConnection,Context.BIND_AUTO_CREATE);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    Log.e("Brodcast","Broadcast intent onCreate invoked");
    if(savedInstanceState == null){
    if(!registred){
        LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver,
                new IntentFilter("my-event"));
        Log.e("Registre","Broadcast intent  register");
        registred = true;
    }}

}
 
開發者ID:RRDL,項目名稱:CRT,代碼行數:27,代碼來源:MainActivity.java

示例2: registerReceiver

import android.content.IntentFilter; //導入依賴的package包/類
private void registerReceiver() {
    if (mRegisteredTimeZoneReceiver) {
        return;
    }
    mRegisteredTimeZoneReceiver = true;
    IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
    MyWatchFace.this.registerReceiver(mTimeZoneReceiver, filter);
}
 
開發者ID:changja88,項目名稱:Android_Sunshine_Watch,代碼行數:9,代碼來源:MyWatchFace.java

示例3: start

import android.content.IntentFilter; //導入依賴的package包/類
public void start(Context context, List<App> appsToMonitor) {
    this.context = context;
    this.appsToMonitor = appsToMonitor;
    this.lastSeenRunningApps = new ArrayList();
    IntentFilter filter = new IntentFilter();
    filter.addAction("android.intent.action.SCREEN_OFF");
    filter.addAction("android.intent.action.SCREEN_ON");
    filter.addAction(ACTION_MONITOR_APPS);
    this.receiver = new AppMonitorReceiver();
    context.registerReceiver(this.receiver, filter);
    if (((PowerManager) context.getSystemService("power")).isScreenOn()) {
        startMonitoring();
    }
}
 
開發者ID:bunnyblue,項目名稱:NoticeDog,代碼行數:15,代碼來源:AppMonitor.java

示例4: startBluetoothServices

import android.content.IntentFilter; //導入依賴的package包/類
/**
 * Starts bluetooth and listens to pairing requests and bluetooth state changes
 */
public static void startBluetoothServices() {
    mReceiver = new BluetoothReceiver();
    //Register the BroadcastReceiver for multiple bluetooth actions

    //when another bluetooth device is discovered in range
    IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);

    //when discovering action finishes (discovering means that bluetooth searches for nearby devices)
    filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
    //when bluetooth changes from on to off
    filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);

    //when another device requests pairing with this device
    filter.addAction(BluetoothDevice.ACTION_PAIRING_REQUEST);

    mainActivity.mainRegisterReceiver(mReceiver, filter);

    if(!started) {
        //tries to start bluetooth if it is not on
       mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
        if(mBluetoothAdapter!=null){
            if (!mBluetoothAdapter.isEnabled()) {
                Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
                mainActivity.startActivityForResult(enableBtIntent, MainActivity.BLUETOOTH_ON);
            } else {
                started = true;
            }
        }

    }
}
 
開發者ID:mcr222,項目名稱:pass_the_bomb,代碼行數:35,代碼來源:BluetoothServices.java

示例5: onCreate

import android.content.IntentFilter; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_usb);

    mStatusView = (TextView) findViewById(R.id.text_status);
    mResultView = (TextView) findViewById(R.id.text_result);

    mUsbManager = getSystemService(UsbManager.class);

    // Detach events are sent as a system-wide broadcast
    IntentFilter filter = new IntentFilter(UsbManager.ACTION_USB_DEVICE_DETACHED);
    registerReceiver(mUsbReceiver, filter);

    handleIntent(getIntent());
}
 
開發者ID:androidthings,項目名稱:sample-usbenum,代碼行數:17,代碼來源:UsbActivity.java

示例6: requestPushToken

import android.content.IntentFilter; //導入依賴的package包/類
void requestPushToken(Activity activity){
    if (activity!=null) {
        Intent service = new Intent(activity, RegistrationIntentService.class);
        service.putExtra(RegistrationIntentService.TOKEN, "token");
        activity.startService(service);

        IntentFilter intentFilter = new IntentFilter(RegistrationIntentService.ACTION_TOKEN);
        intentFilter.addCategory(Intent.CATEGORY_DEFAULT);
        activity.registerReceiver(tokenBroadcastReceiver, intentFilter);

        //send back first
        sendBroadCast();
    }
    else{

    }
}
 
開發者ID:afiqiqmal,項目名稱:MVP-Android,代碼行數:18,代碼來源:SplashPresenter.java

示例7: protectIntentFilter

import android.content.IntentFilter; //導入依賴的package包/類
public static void protectIntentFilter(IntentFilter filter) {
    if (filter != null) {
        List<String> actions = mirror.android.content.IntentFilter.mActions.get(filter);
        ListIterator<String> iterator = actions.listIterator();
        while (iterator.hasNext()) {
            String action = iterator.next();
            if (SpecialComponentList.isActionInBlackList(action)) {
                iterator.remove();
                continue;
            }
            if (SYSTEM_BROADCAST_ACTION.contains(action)) {
                continue;
            }
            String newAction = SpecialComponentList.protectAction(action);
            if (newAction != null) {
                iterator.set(newAction);
            }
        }
    }
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:21,代碼來源:SpecialComponentList.java

示例8: hasSpecializedHandlerIntents

import android.content.IntentFilter; //導入依賴的package包/類
/**
 * Used to check whether there is a specialized handler for a given intent.
 * @param intent The intent to check with.
 * @return Whether there is a specialized handler for the given intent.
 */
private static boolean hasSpecializedHandlerIntents(Context context, Intent intent) {
    try {
        PackageManager pm = context.getPackageManager();
        List<ResolveInfo> handlers = pm.queryIntentActivities(
                intent,
                PackageManager.GET_RESOLVED_FILTER);
        if (handlers == null || handlers.size() == 0) {
            return false;
        }
        for (ResolveInfo resolveInfo : handlers) {
            IntentFilter filter = resolveInfo.filter;
            if (filter == null) continue;
            if (filter.countDataAuthorities() == 0 || filter.countDataPaths() == 0) continue;
            if (resolveInfo.activityInfo == null) continue;
            return true;
        }
    } catch (RuntimeException e) {
        Log.e(TAG, "Runtime exception while getting specialized handlers");
    }
    return false;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:27,代碼來源:CustomTabsHelper.java

示例9: hasSpecializedHandlerIntents

import android.content.IntentFilter; //導入依賴的package包/類
private static boolean hasSpecializedHandlerIntents(Context context, Intent intent) {
    try {
        PackageManager pm = context.getPackageManager();
        List<ResolveInfo> handlers = pm.queryIntentActivities(
                intent,
                PackageManager.GET_RESOLVED_FILTER);
        if (handlers == null || handlers.size() == 0) {
            return false;
        }
        for (ResolveInfo resolveInfo : handlers) {
            IntentFilter filter = resolveInfo.filter;
            if (filter == null) continue;
            if (filter.countDataAuthorities() == 0 || filter.countDataPaths() == 0) continue;
            if (resolveInfo.activityInfo == null) continue;
            return true;
        }
    } catch (RuntimeException e) {
        Log.e("Error", "Runtime exception while getting specialized handlers");
    }
    return false;
}
 
開發者ID:theblixguy,項目名稱:AutoScrollr,代碼行數:22,代碼來源:ChromePackageHelper.java

示例10: registerReceiver

import android.content.IntentFilter; //導入依賴的package包/類
private void registerReceiver() {
    if (mRegisteredTimeZoneReceiver) {
        return;
    }
    mRegisteredTimeZoneReceiver = true;
    IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
    DigitalWatchFaceService.this.registerReceiver(mTimeZoneReceiver, filter);
}
 
開發者ID:gmontoya2483,項目名稱:GoUbiquitous,代碼行數:9,代碼來源:DigitalWatchFaceService.java

示例11: onStart

import android.content.IntentFilter; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public void onStart() {
    super.onStart();
    final IntentFilter filter = new IntentFilter();
    // Play and pause changes
    filter.addAction(MusicPlaybackService.PLAYSTATE_CHANGED);
    // Shuffle and repeat changes
    filter.addAction(MusicPlaybackService.SHUFFLEMODE_CHANGED);
    filter.addAction(MusicPlaybackService.REPEATMODE_CHANGED);
    // Track changes
    filter.addAction(MusicPlaybackService.META_CHANGED);
    // Player prepared
    filter.addAction(MusicPlaybackService.PREPARED);
    // Update a list, probably the playlist fragment's
    filter.addAction(MusicPlaybackService.REFRESH);
    getActivity().registerReceiver(mPlaybackStatus, filter);
    // Refresh the current time
    final long next = refreshCurrentTime();
    queueNextRefresh(next);

    MusicUtils.notifyForegroundStateChanged(getActivity(), isPlaying());
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:26,代碼來源:AudioPlayerFragment.java

示例12: onCreate

import android.content.IntentFilter; //導入依賴的package包/類
public void onCreate(Bundle bundle){
    super.onCreate(bundle);
    mUpdateReceiver = new BroadcastReceiver(){
        @Override
        public void onReceive(Context context, Intent intent) {
            if(intent!=null&& ArchosMediaIntent.ACTION_VIDEO_SCANNER_SCAN_FINISHED.equals(intent.getAction())) {
                getLoaderManager().restartLoader(LOADER_ID_LAST_ADDED, null, MainFragment.this);
                Log.d(TAG, "manual reload");
            }
        }
    };

    mUpdateFilter = new IntentFilter();
    for(String scheme : UriUtils.sIndexableSchemes){
        mUpdateFilter.addDataScheme(scheme);
    }
    mUpdateFilter.addAction(ArchosMediaIntent.ACTION_VIDEO_SCANNER_SCAN_FINISHED);
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:19,代碼來源:MainFragment.java

示例13: registerReceiver

import android.content.IntentFilter; //導入依賴的package包/類
/** 注冊廣播接受來自keyboard的車牌號 */
    public void registerReceiver() {
//        輸入車牌完成後的intent過濾器
        IntentFilter finishFilter = new IntentFilter(INPUT_LICENSE_COMPLETE);
        receiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                String license = intent.getStringExtra(INPUT_LICENSE_KEY);
                if (license != null && license.length() > 0) {
                    if (keyboardUtil != null) {
                        keyboardUtil.hideKeyboard();
                    }
                    KeyBoardPopWindow.this.dismiss();
                    mListener.setLicense(license);
                }
            }
        };
        mContext.registerReceiver(receiver, finishFilter);
    }
 
開發者ID:fengdongfei,項目名稱:CXJPadProject,代碼行數:20,代碼來源:KeyBoardPopWindow.java

示例14: onCreate

import android.content.IntentFilter; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    findViewById(R.id.btn_default).setOnClickListener(this);
    findViewById(R.id.btn_custom).setOnClickListener(this);
    findViewById(R.id.btn_demo).setOnClickListener(this);

    mLlRemoteViewsContainer = (LinearLayout) findViewById(R.id.ll_remote_views);

    mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    IntentFilter intentFilter = new IntentFilter(DemoActivity.ACTION_REMOTE_VIEWS);
    registerReceiver(mBroadcastReceiver, intentFilter);
}
 
開發者ID:DysaniazzZ,項目名稱:ArtOfAndroid,代碼行數:17,代碼來源:MainActivity.java

示例15: btA2dpConnect

import android.content.IntentFilter; //導入依賴的package包/類
@TargetApi(Build.VERSION_CODES.KITKAT)
@RpcMinSdk(Build.VERSION_CODES.KITKAT)
@Rpc(
    description =
            "Connects to a paired or discovered device with A2DP profile."
                    + "If a device has been discovered but not paired, this will pair it."
)
public void btA2dpConnect(String deviceAddress) throws Throwable {
    BluetoothDevice device = BluetoothAdapterSnippet.getKnownDeviceByAddress(deviceAddress);
    IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_PAIRING_REQUEST);
    mContext.registerReceiver(new PairingBroadcastReceiver(mContext), filter);
    Utils.invokeByReflection(sA2dpProfile, "connect", device);
    if (!Utils.waitUntil(
            () -> sA2dpProfile.getConnectionState(device) == BluetoothA2dp.STATE_CONNECTED,
            120)) {
        throw new BluetoothA2dpSnippetException(
                "Failed to connect to device "
                        + device.getName()
                        + "|"
                        + device.getAddress()
                        + " with A2DP profile within 2min.");
    }
}
 
開發者ID:google,項目名稱:mobly-bundled-snippets,代碼行數:24,代碼來源:BluetoothA2dpSnippet.java


注:本文中的android.content.IntentFilter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。