Example usage for android.content Intent getIntArrayExtra

List of usage examples for android.content Intent getIntArrayExtra

Introduction

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

Prototype

public int[] getIntArrayExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:Main.java

public static int[] getIntArrayExtra(Intent intent, String name) {
    if (!hasIntent(intent) || !hasExtra(intent, name))
        return null;
    return intent.getIntArrayExtra(name);
}

From source file:org.chromium.chrome.browser.util.IntentUtils.java

/**
 * Just like {@link Intent#getIntArrayExtra(String)} but doesn't throw exceptions.
 *///from  w  w  w.jav a 2 s.c  o  m
public static int[] safeGetIntArrayExtra(Intent intent, String name) {
    try {
        return intent.getIntArrayExtra(name);
    } catch (Throwable t) {
        // Catches un-parceling exceptions.
        Log.e(TAG, "getIntArrayExtra failed on intent " + intent);
        return null;
    }
}

From source file:me.kaidul.uhunt.ProblemsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    if (intent != null) {
        int[] values = intent.getIntArrayExtra("positions");
        position1 = values[0];/*from  w  w  w.  jav  a 2  s .com*/
        position2 = values[1];
        position3 = values[2];
    }
    setContentView(R.layout.problems);
    if (findViewById(R.id.fragment_container) != null) {
        if (savedInstanceState != null) {
            return;
        }
        ProblemListFragment problemListFrag = new ProblemListFragment();
        getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, problemListFrag).commit();
    }
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

From source file:org.ohmage.reminders.notif.Notifier.java

private static void repeatReminder(Context context, int trigId, Intent intent) {

    TriggerDB db = new TriggerDB(context);
    db.open();//from   w w  w  . j  av a 2  s .  c o  m
    TriggerDB.Campaign campaign = db.getCampaignInfo(trigId);
    db.close();

    Set<String> actSurveys = NotifSurveyAdaptor.getActiveSurveysForTrigger(context, trigId);

    //Check if this trigger is still active. If not cancel all the alarms
    if (actSurveys.size() == 0) {
        cancelAllAlarms(context, trigId);
        return;
    }

    //Trigger is still active, alert the user
    refreshNotification(context, false);
    //Continue the remaining repeat reminders
    int[] repeatDiffs = intent.getIntArrayExtra(KEY_REPEAT_LIST);
    setRepeatAlarm(context, trigId, repeatDiffs);
}

From source file:org.leopub.mat.controller.InboxItemActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_inbox_item);
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }//from w  ww .  j  a  v a  2s . c om

    mUser = UserManager.getInstance().getCurrentUser();

    Intent intent = getIntent();
    int[] itemIdArray = intent.getIntArrayExtra(INBOX_ITEM_MSG_ID);
    mItemIdStack = new Stack<>();
    for (int itemId : itemIdArray) {
        mItemIdStack.push(itemId);
    }
    mItem = mUser.getInboxItemByMsgId(mItemIdStack.pop());
    updateView();
    mBroadcastReceiver = new MessageBroadcastReceiver();
    IntentFilter filter = new IntentFilter(Configure.BROADCAST_MESSAGE);
    LocalBroadcastManager.getInstance(MyApplication.getAppContext()).registerReceiver(mBroadcastReceiver,
            filter);
}

From source file:com.zns.comicdroid.activity.Edit.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_edit);
    super.onCreate(savedInstanceState);

    mDateFormat = android.text.format.DateFormat.getDateFormat(this);
    mEtTitle = (EditText) findViewById(R.id.comicEdit_etTitle);
    mEtSubtitle = (EditText) findViewById(R.id.comicEdit_etSubtitle);
    mEtIssue = (EditText) findViewById(R.id.comicEdit_etIssue);
    mEtIssues = (EditText) findViewById(R.id.comicEdit_etIssues);
    mEtAuthor = (AutoCompleteTextView) findViewById(R.id.comicEdit_actAuthor);
    mEtIllustrator = (AutoCompleteTextView) findViewById(R.id.comicEdit_actIllustrator);
    mEtPublisher = (AutoCompleteTextView) findViewById(R.id.comicEdit_actPublisher);
    mEtPublished = (EditText) findViewById(R.id.comicEdit_etPublished);
    mEtAdded = (EditText) findViewById(R.id.comicEdit_etAdded);
    mEtPageCount = (EditText) findViewById(R.id.comicEdit_etPageCount);
    mIvImage = (ImageView) findViewById(R.id.comicEdit_ivImage);
    mSpGroup = (Spinner) findViewById(R.id.comicEdit_spGroup);
    mIvGroupAdd = (ImageView) findViewById(R.id.comicEdit_ivGroupAdd);
    mRowIssue = (RelativeLayout) findViewById(R.id.comicEdit_issue);
    mRowPublishDate = (RelativeLayout) findViewById(R.id.comicEdit_publishDate);
    mRowAdded = (RelativeLayout) findViewById(R.id.comicEdit_added);
    mRowPageCount = (RelativeLayout) findViewById(R.id.comicEdit_pageCount);
    mRowIssues = (RelativeLayout) findViewById(R.id.comicEdit_issues);
    AndroidSlidingDrawer drawer = (AndroidSlidingDrawer) findViewById(R.id.comicEdit_drawer);

    Intent intent = getIntent();
    int[] comicIds = intent.getIntArrayExtra(INTENT_COMIC_IDS);

    //Spinner groups
    List<Group> groups = getDBHelper().getGroups();
    if (groups == null)
        groups = new ArrayList<Group>();
    groups.add(0, new Group(0, getResources().getString(R.string.common_nogroup), null, 0, 0, 0, 0, 0));
    mAdapterGroups = new ArrayAdapter<Group>(this, android.R.layout.simple_spinner_item, groups);
    mAdapterGroups.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mSpGroup.setAdapter(mAdapterGroups);

    //Dialog/* w w  w .j a v a  2s  .  c o m*/
    mIvGroupAdd.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            DialogFragment dialogAddGroup = new GroupDialogFragment();
            dialogAddGroup.show(getSupportFragmentManager(), "GROUPADD");
        }
    });

    //Autocomplete author
    mAdapterAuthors = new AutoCompleteAdapter(this,
            "SELECT DISTINCT 0 AS _id, Author FROM tblBooks WHERE Author LIKE ? ORDER BY Author", "Author", 1);
    mEtAuthor.setThreshold(3);
    mEtAuthor.setAdapter(mAdapterAuthors);

    //Autocomplete illustrator
    mAdapterIllustrators = new AutoCompleteAdapter(this,
            "SELECT DISTINCT 0 AS _id, Illustrator FROM tblBooks WHERE Illustrator LIKE ? ORDER BY Illustrator",
            "Illustrator", 1);
    mEtIllustrator.setThreshold(3);
    mEtIllustrator.setAdapter(mAdapterIllustrators);

    //Autocomplete publisher
    mAdapterPublisher = new AutoCompleteAdapter(this,
            "SELECT DISTINCT 0 AS _id, Publisher FROM tblBooks WHERE Publisher LIKE ? ORDER BY Publisher",
            "Publisher", 1);
    mEtPublisher.setThreshold(3);
    mEtPublisher.setAdapter(mAdapterPublisher);

    if (comicIds != null && comicIds.length > 0) {
        mComics = getDBHelper().getComics(comicIds);

        ListView lvEdit = (ListView) findViewById(R.id.comicEdit_listView);
        if (comicIds.length > 1) {
            drawer.setVisibility(View.VISIBLE);
            ComicArrayAdapter adapter = new ComicArrayAdapter(this, mComics, getImagePath(true));
            lvEdit.setAdapter(adapter);
        } else {
            mIvImage.setOnClickListener(this);
            drawer.setVisibility(View.GONE);
        }

        BindComics();
    } else {
        mIvImage.setOnClickListener(this);
        drawer.setVisibility(View.GONE);
    }
}

From source file:eu.power_switch.gui.fragment.phone.CallEventsFragment.java

@Override
public void onCreateViewEvent(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.fragment_call_events, container, false);

    setHasOptionsMenu(true);/*from   w  w  w  .  j a  v a  2 s  .c  o  m*/

    recyclerViewCalls = (RecyclerView) rootView.findViewById(R.id.recyclerView);
    callRecyclerViewAdapter = new CallRecyclerViewAdapter(getActivity(), callEvents);
    recyclerViewCalls.setAdapter(callRecyclerViewAdapter);
    StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(getSpanCount(),
            StaggeredGridLayoutManager.VERTICAL);
    recyclerViewCalls.setLayoutManager(layoutManager);

    final RecyclerViewFragment recyclerViewFragment = this;

    fab = (FloatingActionButton) rootView.findViewById(R.id.add_fab);
    fab.setImageDrawable(IconicsHelper.getAddIcon(getActivity(),
            ContextCompat.getColor(getActivity(), android.R.color.white)));
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!PermissionHelper.isPhonePermissionAvailable(getContext())) {
                new AlertDialog.Builder(getContext()).setTitle(R.string.missing_permission)
                        .setMessage(R.string.missing_contacts_permission).setNeutralButton(R.string.close, null)
                        .show();
                return;
            }

            ConfigureCallEventDialog configureCallEventDialog = new ConfigureCallEventDialog();
            configureCallEventDialog.setTargetFragment(recyclerViewFragment, 0);
            configureCallEventDialog.show(getFragmentManager(), null);
        }
    });

    // BroadcastReceiver to get notifications from background service if room data has changed
    broadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            Log.d(this, "received intent: " + intent.getAction());

            switch (intent.getAction()) {
            case LocalBroadcastConstants.INTENT_CALL_EVENTS_CHANGED:
                refreshCalls();
                break;
            case LocalBroadcastConstants.INTENT_PERMISSION_CHANGED:
                int permissionRequestCode = intent.getIntExtra(PermissionConstants.KEY_REQUEST_CODE, 0);
                int[] result = intent.getIntArrayExtra(PermissionConstants.KEY_RESULTS);

                if (permissionRequestCode == PermissionConstants.REQUEST_CODE_PHONE_PERMISSION) {
                    boolean allGranted = true;
                    for (int i = 0; i < result.length; i++) {
                        allGranted &= result[i] == PackageManager.PERMISSION_GRANTED;
                    }

                    if (allGranted) {
                        StatusMessageHandler.showInfoMessage(getRecyclerView(), R.string.permission_granted,
                                Snackbar.LENGTH_SHORT);

                        sendCallEventsChangedBroadcast(context);
                    } else {
                        StatusMessageHandler.showPermissionMissingMessage(getActivity(), getRecyclerView(),
                                Manifest.permission.READ_PHONE_STATE, Manifest.permission.READ_CONTACTS);
                    }
                }
                break;
            }
        }
    };
}

From source file:eu.power_switch.gui.fragment.geofences.CustomGeofencesFragment.java

@Override
public void onCreateViewEvent(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.fragment_custom_geofences, container, false);

    setHasOptionsMenu(true);//  w w w.  j  a  v  a  2 s.  c om

    geofenceApiHandler = new GeofenceApiHandler(getActivity());

    recyclerViewGeofences = (RecyclerView) rootView.findViewById(R.id.recyclerView);
    geofenceRecyclerViewAdapter = new GeofenceRecyclerViewAdapter(getActivity(), geofences, geofenceApiHandler);
    recyclerViewGeofences.setAdapter(geofenceRecyclerViewAdapter);
    StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(getSpanCount(),
            StaggeredGridLayoutManager.VERTICAL);
    recyclerViewGeofences.setLayoutManager(layoutManager);

    final RecyclerViewFragment recyclerViewFragment = this;
    geofenceRecyclerViewAdapter
            .setOnItemLongClickListener(new GeofenceRecyclerViewAdapter.OnItemLongClickListener() {
                @Override
                public void onItemLongClick(View itemView, int position) {
                    final Geofence geofence = geofences.get(position);

                    ConfigureGeofenceDialog configureGeofenceDialog = ConfigureGeofenceDialog
                            .newInstance(geofence.getId());
                    configureGeofenceDialog.setTargetFragment(recyclerViewFragment, 0);
                    configureGeofenceDialog.show(getFragmentManager(), null);
                }
            });

    fab = (FloatingActionButton) rootView.findViewById(R.id.add_fab);
    fab.setImageDrawable(IconicsHelper.getAddIcon(getActivity(),
            ContextCompat.getColor(getActivity(), android.R.color.white)));
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!PermissionHelper.isLocationPermissionAvailable(getContext())) {
                new AlertDialog.Builder(getContext()).setTitle(R.string.missing_permission)
                        .setMessage(R.string.missing_location_permission).setNeutralButton(R.string.close, null)
                        .show();
                return;
            }

            ConfigureGeofenceDialog configureGeofenceDialog = new ConfigureGeofenceDialog();
            configureGeofenceDialog.setTargetFragment(recyclerViewFragment, 0);
            configureGeofenceDialog.show(getFragmentManager(), null);
        }
    });

    // BroadcastReceiver to get notifications from background service if room data has changed
    broadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            Log.d(this, "received intent: " + intent.getAction());

            switch (intent.getAction()) {
            case LocalBroadcastConstants.INTENT_CUSTOM_GEOFENCE_CHANGED:
                refreshGeofences();
                break;
            case LocalBroadcastConstants.INTENT_PERMISSION_CHANGED:
                int permissionRequestCode = intent.getIntExtra(PermissionConstants.KEY_REQUEST_CODE, 0);
                int[] result = intent.getIntArrayExtra(PermissionConstants.KEY_RESULTS);

                if (permissionRequestCode == PermissionConstants.REQUEST_CODE_LOCATION_PERMISSION) {
                    if (result[0] == PackageManager.PERMISSION_GRANTED) {
                        StatusMessageHandler.showInfoMessage(getRecyclerView(), R.string.permission_granted,
                                Snackbar.LENGTH_SHORT);

                        sendCustomGeofencesChangedBroadcast(context);
                    } else {
                        StatusMessageHandler.showPermissionMissingMessage(getActivity(), getRecyclerView(),
                                Manifest.permission.ACCESS_FINE_LOCATION);
                    }
                }
                break;
            }

        }
    };
}

From source file:org.restcomm.app.qoslib.Utils.EventHistoryFragment.java

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    View view = inflater.inflate(R.layout.frag_eventhistory, null, false);

    //TextView mapHistoryTitle = (TextView) view.findViewById(R.id.actionbartitle);

    Intent intent = this.getActivity().getIntent();
    boolean bFromStats = false;
    boolean bFromNerd = false;
    HashSet<Integer> eventsToDisplay = new HashSet<Integer>();

    int eventtype = 0;
    if (intent.hasExtra("eventtype"))
        eventtype = intent.getIntExtra("eventtype", 0);
    int[] eventtypes;
    if (intent.hasExtra("eventtypes")) {
        eventtypes = intent.getIntArrayExtra("eventtypes");
        for (int i = 0; i < eventtypes.length; i++)
            eventsToDisplay.add(eventtypes[i]);
    }/*from  w  ww. j av a2 s.  c  om*/

    mEmptyMessage = (TextView) getActivity().findViewById(R.id.eventhistory_emptymessage);

    if (eventtype > 0)
        eventsToDisplay.add(eventtype);

    //load lat/lons for locations before trying to geocode
    preGeocode(eventsToDisplay);

    return view;
}

From source file:eu.power_switch.gui.fragment.geofences.ApartmentGeofencesFragment.java

@Override
public void onCreateViewEvent(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.fragment_apartment_geofences, container, false);

    setHasOptionsMenu(true);//from   w  w w .  j  a  va2s.  co m

    geofenceApiHandler = new GeofenceApiHandler(getActivity());

    recyclerViewGeofences = (RecyclerView) rootView.findViewById(R.id.recyclerView);
    geofenceRecyclerViewAdapter = new GeofenceRecyclerViewAdapter(getActivity(), geofences, geofenceApiHandler);
    recyclerViewGeofences.setAdapter(geofenceRecyclerViewAdapter);
    StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(getSpanCount(),
            StaggeredGridLayoutManager.VERTICAL);
    recyclerViewGeofences.setLayoutManager(layoutManager);

    final RecyclerViewFragment recyclerViewFragment = this;
    geofenceRecyclerViewAdapter
            .setOnItemLongClickListener(new GeofenceRecyclerViewAdapter.OnItemLongClickListener() {
                @Override
                public void onItemLongClick(View itemView, int position) {
                    final Geofence geofence = geofences.get(position);

                    ConfigureApartmentGeofenceDialog configureApartmentGeofenceDialog = ConfigureApartmentGeofenceDialog
                            .newInstance(geofenceIdApartmentMap.get(geofence.getId()).getId());
                    configureApartmentGeofenceDialog.setTargetFragment(recyclerViewFragment, 0);
                    configureApartmentGeofenceDialog.show(getFragmentManager(), null);
                }
            });

    fab = (FloatingActionButton) rootView.findViewById(R.id.add_fab);
    fab.setImageDrawable(IconicsHelper.getAddIcon(getActivity(),
            ContextCompat.getColor(getActivity(), android.R.color.white)));
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!PermissionHelper.isLocationPermissionAvailable(getContext())) {
                new AlertDialog.Builder(getContext()).setTitle(R.string.missing_permission)
                        .setMessage(R.string.missing_location_permission).setNeutralButton(R.string.close, null)
                        .show();
                return;
            }

            try {
                int apartmentsCount = DatabaseHandler.getAllApartments().size();

                if (apartmentsCount == 0) {
                    new AlertDialog.Builder(getContext())
                            .setMessage(R.string.please_create_or_activate_apartment_first)
                            .setNeutralButton(android.R.string.ok, null).show();
                    return;
                } else if (DatabaseHandler.getAllApartments().size() == geofences.size()) {
                    new AlertDialog.Builder(getContext()).setMessage(R.string.all_apartments_have_geofence)
                            .setNeutralButton(android.R.string.ok, null).show();
                    return;
                }
            } catch (Exception e) {
                StatusMessageHandler.showErrorMessage(recyclerViewFragment.getRecyclerView(), e);
                return;
            }

            SelectApartmentForGeofenceDialog selectApartmentForGeofenceDialog = new SelectApartmentForGeofenceDialog();
            selectApartmentForGeofenceDialog.setTargetFragment(recyclerViewFragment, 0);
            selectApartmentForGeofenceDialog.show(getFragmentManager(), null);
        }
    });

    // BroadcastReceiver to get notifications from background service if room data has changed
    broadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            Log.d(this, "received intent: " + intent.getAction());

            switch (intent.getAction()) {
            case LocalBroadcastConstants.INTENT_APARTMENT_GEOFENCE_CHANGED:
                refreshGeofences();
                break;
            case LocalBroadcastConstants.INTENT_PERMISSION_CHANGED:
                int permissionRequestCode = intent.getIntExtra(PermissionConstants.KEY_REQUEST_CODE, 0);
                int[] result = intent.getIntArrayExtra(PermissionConstants.KEY_RESULTS);

                if (permissionRequestCode == PermissionConstants.REQUEST_CODE_LOCATION_PERMISSION) {
                    if (result[0] == PackageManager.PERMISSION_GRANTED) {
                        StatusMessageHandler.showInfoMessage(getRecyclerView(), R.string.permission_granted,
                                Snackbar.LENGTH_SHORT);

                        sendApartmentGeofencesChangedBroadcast(context);
                    } else {
                        StatusMessageHandler.showPermissionMissingMessage(getActivity(), getRecyclerView(),
                                Manifest.permission.ACCESS_FINE_LOCATION);
                    }
                }
                break;
            }
        }
    };
}