Example usage for android.app ActionBar setDisplayHomeAsUpEnabled

List of usage examples for android.app ActionBar setDisplayHomeAsUpEnabled

Introduction

In this page you can find the example usage for android.app ActionBar setDisplayHomeAsUpEnabled.

Prototype

public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp);

Source Link

Document

Set whether home should be displayed as an "up" affordance.

Usage

From source file:com.concentricsky.android.khanacademy.app.TopicListActivity.java

@Override
protected void onStart() {
    super.onStart();

    stopped = false;/*from w  w  w. j a  v a  2 s.co  m*/

    mainMenuDelegate = new MainMenuDelegate(this);
    gridView = (GridView) findViewById(R.id.activity_topic_list_grid);
    gridView.setOnItemClickListener(clickListener);

    ActionBar ab = getActionBar();
    ab.setDisplayHomeAsUpEnabled(true);
    ab.setTitle("Topics");

    requestDataService(new ObjectCallback<KADataService>() {
        @Override
        public void call(final KADataService dataService) {
            TopicListActivity.this.dataService = dataService;

            try {
                thumbnailManager = dataService.getThumbnailManager();

                dao = dataService.getHelper().getTopicDao();
                if (topicId != null) {
                    topic = dao.queryForId(topicId);
                } else {
                    topic = dataService.getRootTopic();
                    topicId = topic.getId();
                }

                // DEBUG
                if (topic == null)
                    return;

                // header
                headerView = findViewById(R.id.header_topic_list);

                ((TextView) headerView.findViewById(R.id.header_video_list_title)).setText(topic.getTitle());

                String desc = topic.getDescription();
                TextView descView = (TextView) headerView.findViewById(R.id.header_video_list_description);
                if (desc != null && desc.length() > 0) {
                    descView.setText(Html.fromHtml(desc));
                    descView.setVisibility(View.VISIBLE);
                } else {
                    descView.setVisibility(View.GONE);
                }

                // Find child count for this parent topic.
                boolean videoChildren = Topic.CHILD_KIND_VIDEO.equals(topic.getChild_kind());
                String[] idArg = { topic.getId() };
                String sql = videoChildren ? "select count() from topicvideo where topic_id=?"
                        : "select count() from topic where parentTopic_id=?";
                int count = (int) dao.queryRawValue(sql, idArg);
                String countFormat = getString(
                        videoChildren ? R.string.format_video_count : R.string.format_topic_count);

                // Set header count string.
                ((TextView) headerView.findViewById(R.id.header_video_list_count))
                        .setText(String.format(countFormat, count));

                final ImageView thumb = (ImageView) headerView.findViewById(R.id.header_video_list_thumbnail);
                if (thumb != null) {
                    new AsyncTask<Void, Void, Bitmap>() {
                        @Override
                        public Bitmap doInBackground(Void... arg) {
                            Bitmap bmp = thumbnailManager.getThumbnail(
                                    TopicListActivity.this.topic.getThumb_id(), Thumbnail.QUALITY_SD);
                            return bmp;
                        }

                        @Override
                        public void onPostExecute(Bitmap bmp) {
                            thumb.setImageBitmap(bmp);
                        }
                    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                }

                // list
                if (topicCursor != null) {
                    topicCursor.close();
                }
                topicCursor = buildCursor(topicId);

                ListAdapter adapter = new TopicGridAdapter(topicCursor);
                gridView.setAdapter(adapter);

                // Request the topic and its children be updated from the api.
                List<Topic> children = dao.queryForEq("parentTopic_id", topic.getId());
                List<String> toUpdate = new ArrayList<String>();
                for (Topic child : children) {
                    toUpdate.add(child.getId());
                }
                toUpdate.add(topic.getId());
            } catch (SQLException e) {
                e.printStackTrace();
            }

        }
    });

    IntentFilter filter = new IntentFilter();
    filter.addAction(ACTION_LIBRARY_UPDATE);
    filter.addAction(ACTION_BADGE_EARNED);
    filter.addAction(ACTION_TOAST);
    LocalBroadcastManager.getInstance(this).registerReceiver(receiver, filter);
}

From source file:com.xortech.multitag.TagAddUpdate.java

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

    // REMOVE THE TITLE FROM THE ACTIONBAR
    ActionBar actionbar = getActionBar();
    actionbar.setDisplayHomeAsUpEnabled(true);
    actionbar.setDisplayShowTitleEnabled(false);

    // SET UP THE SCREEN
    Set_Add_Update_Screen();/*from w w w  .j a v a2 s  . c om*/

    // SET THE VISIBILITY
    String called_from = getIntent().getStringExtra("called");

    if (called_from.equalsIgnoreCase("add")) {
        add_view.setVisibility(View.VISIBLE);
        update_view.setVisibility(View.GONE);
    } else {
        update_view.setVisibility(View.VISIBLE);
        add_view.setVisibility(View.GONE);
        USER_ID = Integer.parseInt(getIntent().getStringExtra("USER_ID"));

        MyTags c = dbHandler.Get_Tag(USER_ID);

        add_tag.setText(c.getMyTag());
        add_mobile.setText(c.getMyTagPhoneNumber());
        add_secret.setText(c.getTagSecret());
        active = c.getTagStatus();

        dbHandler.close();
    }

    add_mobile.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO: Auto-generated method stub
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub
        }

        @Override
        public void afterTextChanged(Editable s) {
            Is_Valid_Sign_Number_Validation(6, 16, add_mobile);
        }
    });

    add_secret.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO: Auto-generated method stub
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub
        }

        @Override
        public void afterTextChanged(Editable s) {
            Is_Valid_Secret(add_secret);
        }
    });

    add_tag.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO Auto-generated method stub 
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub
        }

        @Override
        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub
            Is_Valid_Tag_Name(add_tag);
        }
    });

    add_save_btn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (valid_tag != null && valid_mob_number != null && valid_secret != null && valid_tag.length() != 0
                    && valid_mob_number.length() != 0 && valid_secret.length() != 0) {

                newTag = new MyTags(valid_tag, valid_mob_number, valid_secret, 1);

                dbHandler.Add_Tag(newTag);
                toastMsg = "Tag Added";
                Show_Toast(toastMsg);
                ResetText();
                ResetError();
                ReturnToMain();
            } else {
                VibrateError(add_tag, add_mobile, add_secret);
                toastMsg = "Invalid Input!";
                Show_Toast(toastMsg);
                ResetText();
                ResetError();
            }
        }
    });

    update_btn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            valid_tag = add_tag.getText().toString();
            valid_mob_number = add_mobile.getText().toString();
            valid_secret = add_secret.getText().toString();

            // CHECK IF THE VALUE STATE IS NULL OR NOT
            if (valid_tag != null && valid_mob_number != null && valid_secret != null && valid_tag.length() != 0
                    && valid_mob_number.length() != 0 && valid_secret.length() != 0) {

                newTag = new MyTags(USER_ID, valid_tag, valid_mob_number, valid_secret, active);

                dbHandler.Update_Tag(newTag);
                dbHandler.close();
                toastMsg = "Tag Update Successful";
                Show_Toast(toastMsg);
                ResetText();
                ResetError();
                ReturnToMain();
            } else {
                VibrateError(add_tag, add_mobile, add_secret);
                toastMsg = "Invalid input detected.\nPlease fill in all fields.";
                Show_Toast(toastMsg);
                ResetError();
            }
        }
    });

    update_view_all.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ReturnToMain();
        }
    });

    add_view_all.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ReturnToMain();
        }
    });
}

From source file:com.commonsware.android.feedfrags.FeedsNavActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_nav);//from  w w w.java2s .com

    ActionBar bar = getActionBar();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        adapter = new ArrayAdapter<Feed>(bar.getThemedContext(), R.layout.row, Feed.getFeeds());
    } else {
        adapter = new ArrayAdapter<Feed>(this, R.layout.row, Feed.getFeeds());
    }

    bar.setListNavigationCallbacks(adapter, new NavListener());
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
    bar.setDisplayHomeAsUpEnabled(true);
}

From source file:com.mishiranu.dashchan.util.DrawerToggle.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public void setDrawerIndicatorMode(int mode) {
    if (this.mode != mode) {
        this.mode = mode;
        ActionBar actionBar = activity.getActionBar();
        if (mode == MODE_DISABLED) {
            if (C.API_JELLY_BEAN_MR2) {
                actionBar.setHomeAsUpIndicator(null);
            }/* w  ww  .j  av  a  2s .c om*/
            actionBar.setDisplayHomeAsUpEnabled(false);
        } else {
            actionBar.setDisplayHomeAsUpEnabled(true);
            if (C.API_LOLLIPOP) {
                activity.getActionBar().setHomeAsUpIndicator(arrowDrawable);
                boolean open = drawerLayout.isDrawerOpen(Gravity.START) && arrowDrawable.position == 1f;
                if (!open) {
                    ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f);
                    animator.setDuration(DRAWER_CLOSE_DURATION);
                    animator.addUpdateListener(new StateArrowAnimatorListener(mode == MODE_DRAWER));
                    animator.start();
                }
            } else {
                setActionBarUpIndicatorObsolete(mode == MODE_DRAWER ? slideDrawable : homeAsUpIndicator);
            }
        }
    }
}

From source file:org.travey.travey.QuestionActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Set up action bar.
    final ActionBar actionBar = getActionBar();
    // Specify that the Home button should show an "Up" caret, indicating that touching the
    // button will take the user one step up in the application's hierarchy.
    actionBar.setDisplayHomeAsUpEnabled(true);
    //load properties from config resource file
    Resources res = getResources();
    RESTFUL_URL = res.getString(R.string.restful_url);
    SURVEY_ID = res.getString(R.string.survey_id);
    NUMBER_QUESTIONS = res.getInteger(R.integer.number_of_survey_questions_used);
    //get preferences
    myPrefs = this.getSharedPreferences("myPrefs", MODE_PRIVATE);
    participantID = myPrefs.getString("participantID", "");
    myPrefsEditor = myPrefs.edit();/*  ww  w . j  a  v  a 2 s .  co  m*/
    setTitle(R.string.trip_notification_title);
    setContentView(R.layout.activity_question);

    Button button = (Button) findViewById(R.id.button);
    button.setOnClickListener(new Button.OnClickListener() {
        @Override
        public void onClick(View view) {
            Log.i("**************", "butclick");
            // Do something in response to button
            // transmit data to a database
            Log.i("**************", "Submitting to database");
            //get the trip data
            Intent i = getIntent();
            DataConnection dataConnection = new DataConnection();
            //need to add answers to questions
            String url = RESTFUL_URL + "?method=trip-questions-only&format=json&pid=" + participantID + "&sid="
                    + SURVEY_ID + "&tid=" + i.getStringExtra("tripId") + "&q1a=" + question1Answer + "&q2a="
                    + question2Answer + "&q3a=" + question3Answer + "&q4a=" + question4Answer + "&q5a="
                    + question5Answer + "&q6a=" + question6Answer + "&q7a=" + question7Answer + "&q8a="
                    + question8Answer;
            Log.i("**************", "Submitting: " + url);
            dataConnection.connect(QuestionActivity.this, url);
            Log.i("**************", "Setting notification pref to false");
            myPrefsEditor.putLong("lastTouchTime", new Date().getTime());
            myPrefsEditor.putBoolean("isNotified", false);
            myPrefsEditor.commit();
            QuestionActivity.this.finish();
        }
    });

    mapView = (MapView) findViewById(R.id.mapview);
    mapView.setTileSource(TileSourceFactory.MAPNIK);
    mapView.setBuiltInZoomControls(false);
    mapController = mapView.getController();
    mapController.setZoom(18); //this is the max level
    Intent i = getIntent();
    Double lat = Double.parseDouble(i.getStringExtra("originLatitude"));
    Double lon = Double.parseDouble(i.getStringExtra("originLongitude"));
    GeoPoint point1 = new GeoPoint((int) (lat * 1e6), (int) (lon * 1e6));
    lat = Double.parseDouble(i.getStringExtra("destinationLatitude"));
    lon = Double.parseDouble(i.getStringExtra("destinationLongitude"));
    GeoPoint point2 = new GeoPoint((int) (lat * 1e6), (int) (lon * 1e6));
    mapController.setCenter(point2);
    ArrayList<OverlayItem> overlayItemArray = new ArrayList<OverlayItem>();
    overlayItemArray.add(new OverlayItem("0", "0", new GeoPoint(lat, lon)));
    ItemizedIconOverlay<OverlayItem> anotherItemizedIconOverlay = new ItemizedIconOverlay<OverlayItem>(this,
            overlayItemArray, null);
    mapView.getOverlays().add(anotherItemizedIconOverlay);
    //Add Scale Bar
    ScaleBarOverlay myScaleBarOverlay = new ScaleBarOverlay(this);
    mapView.getOverlays().add(myScaleBarOverlay);

    prepareQuestions();
}

From source file:com.plnyyanks.frcnotebook.activities.ViewTeam.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(PreferenceHandler.getTheme());
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_team);

    activity = this;

    ActionBar bar = getActionBar();
    bar.setTitle(teamNumber != -1 ? "Team " + teamNumber : "All Data");

    //tab for team overview
    ActionBar.Tab teamOverviewTab = bar.newTab();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    teamOverviewTab.setText("All Notes");
    teamOverviewTab.setTag("all");
    teamOverviewTab.setTabListener(this);
    bar.addTab(teamOverviewTab);/*from  ww w  .jav a2 s  . c om*/
    bar.setDisplayHomeAsUpEnabled(true);

    //add an actionbar tab for every event the team is competing at
    ArrayList<String> events;
    if (teamNumber == -1) {
        events = StartActivity.db.getAllEventKeys();
    } else {
        Team team = StartActivity.db.getTeam(teamKey);
        events = team.getTeamEvents();
    }
    for (String eventKey : events) {
        Log.d(Constants.LOG_TAG, "Making AB Tab for " + eventKey);
        Event event = StartActivity.db.getEvent(eventKey);
        if (event == null)
            continue;
        ActionBar.Tab eventTab = bar.newTab();
        eventTab.setTag(event.getEventKey());
        eventTab.setText(event.getShortName());
        eventTab.setTabListener(this);
        bar.addTab(eventTab);
    }

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt(STATE_SELECTED_NAVIGATION_ITEM, 0));
    } else {
        bar.setSelectedNavigationItem(0);
    }

}

From source file:com.xortech.multipanic.PanicAddUpdate.java

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

    // REMOVE THE TITLE FROM THE ACTIONBAR
    ActionBar actionbar = getActionBar();
    actionbar.setDisplayHomeAsUpEnabled(true);
    actionbar.setDisplayShowTitleEnabled(false);

    // SET THE SCREEN
    Set_Add_Update_Screen();//from w  w w . ja  va2s .  c  om

    // SET VISIBILITY OF VIEW AS PER CALLING ACTIVITY
    String called_from = getIntent().getStringExtra("called");

    if (called_from.equalsIgnoreCase("add")) {
        add_view.setVisibility(View.VISIBLE);
        update_view.setVisibility(View.GONE);
    } else {
        update_view.setVisibility(View.VISIBLE);
        add_view.setVisibility(View.GONE);

        USER_ID = Integer.parseInt(getIntent().getStringExtra("USER_ID"));

        MyPanicNumbers c = dbHandler.Get_Numbers(USER_ID);

        add_tag.setText(c.getMyPanicTag());
        add_mobile.setText(c.getMyPanicPhoneNumber());
        add_email.setText(c.getMyPanicEmail());
        tActive = c.getPanicActive();
        pActive = c.getPanicActiveP();
        eActive = c.getPanicActiveE();
        dbHandler.close();
    }

    add_mobile.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO: Auto-generated method stub
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub
        }

        @Override
        public void afterTextChanged(Editable s) {
            Is_Valid_Sign_Number_Validation(6, 16, add_mobile);
        }
    });

    add_tag.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO: Auto-generated method stub
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub
        }

        @Override
        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub
            Is_Valid_Tag_Name(15, add_tag);
        }
    });

    add_email.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO: 
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub
        }

        @Override
        public void afterTextChanged(Editable s) {
            Is_Valid_Email(25, add_email);
        }
    });

    add_save_btn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            if (valid_tag != null && valid_mob_number != null && valid_tag.length() != 0
                    && valid_mob_number.length() != 0) {

                newPanic = new MyPanicNumbers(valid_tag, valid_mob_number, valid_email, 1, 1, 1);

                dbHandler.Add_Number(newPanic);
                dbHandler.close();
                toastMsg = "Tag Added";
                Show_Toast(toastMsg);
                ResetText();
                ResetError();
                ReturnToMain();
            } else {
                VibrateError(add_tag, add_mobile, add_email);
                toastMsg = "Invalid Input!";
                Show_Toast(toastMsg);
                ResetText();
                ResetError();
            }
        }
    });

    update_btn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            valid_tag = add_tag.getText().toString();
            valid_mob_number = add_mobile.getText().toString();
            valid_email = add_email.getText().toString();

            // check the value state is null or not
            if (valid_tag != null && valid_mob_number != null && valid_tag.length() != 0
                    && valid_mob_number.length() != 0) {

                newPanic = new MyPanicNumbers(USER_ID, valid_tag, valid_mob_number, valid_email, tActive,
                        pActive, eActive);

                dbHandler.Update_Number(newPanic);
                dbHandler.close();
                toastMsg = "Tag Update Successful";
                Show_Toast(toastMsg);
                ResetText();
                ResetError();
                ReturnToMain();
            } else {
                VibrateError(add_tag, add_mobile, add_email);
                toastMsg = "Invalid input detected.\nPlease fill in all fields.";
                Show_Toast(toastMsg);
                ResetError();
            }
        }
    });

    update_view_all.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ReturnToMain();
        }
    });

    add_view_all.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ReturnToMain();
        }
    });
}

From source file:com.example.lowviscam.GalleryActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    isLight = getIntent().getExtras().getBoolean("isLight");
    if (isLight == false) {
        this.setTheme(R.style.AppBaseThemeDark);
    } else {/*from www.  j  a v a 2 s .c om*/
        this.setTheme(R.style.AppBaseTheme);
    }
    setContentView(R.layout.activity_gallery);

    // Retrieve APHont font and apply it
    mFace = Typeface.createFromAsset(getAssets(), "fonts/APHont-Regular_q15c.otf");
    SpannableString s = new SpannableString("Image Gallery");
    s.setSpan(new TypefaceSpan(this, "APHont-Bold_q15c.otf"), 0, s.length(),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    // Update the action bar title with the TypefaceSpan instance
    ActionBar actionBar = getActionBar();
    actionBar.setTitle(s);

    actionBar.setDisplayHomeAsUpEnabled(true);

    // Fetch the {@link LayoutInflater} service so that new views can be created
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    // Find the {@link GridView} that was already defined in the XML layout
    GridView gridView = (GridView) findViewById(R.id.grid);

    // Initialize the adapter with all the coupons. Set the adapter on the {@link GridView}.
    try {
        gridView.setAdapter(new CouponAdapter(inflater, createAllCoupons()));
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    // Set a click listener for each picture in the grid
    gridView.setOnItemClickListener(this);
    gridView.setOnTouchListener(new OnSwipeTouchListener() {

        public void onSwipeTop() {
            //Toast.makeText(GalleryActivity.this, "top", Toast.LENGTH_SHORT).show();
        }

        public void onSwipeRight() {
            //Toast.makeText(GalleryActivity.this, "right", Toast.LENGTH_SHORT).show();
        }

        public void onSwipeLeft() {
            //Toast.makeText(GalleryActivity.this, "left", Toast.LENGTH_SHORT).show();
        }

        public void onSwipeBottom() {
            //Toast.makeText(GalleryActivity.this, "bottom", Toast.LENGTH_SHORT).show();
        }

    });
    gridView.setOnItemLongClickListener(new OnItemLongClickListener() {

        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            // Find coupon that was clicked based off of position in adapter
            Coupon coupon = (Coupon) parent.getItemAtPosition(position);
            //Get absolutepath of image for adding.
            File list[] = mediaStorageDir.listFiles();
            File tmpFile = list[list.length - position - 1];
            String photoUri = coupon.mImageUri.toString();
            try {
                photoUri = MediaStore.Images.Media.insertImage(getContentResolver(), tmpFile.getAbsolutePath(),
                        null, null);
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            // Create share intent
            Intent shareIntent = ShareCompat.IntentBuilder.from(GalleryActivity.this).setText(coupon.mTitle)
                    .setType("image/jpeg").setStream(Uri.parse(photoUri))
                    .setChooserTitle(getString(R.string.share_using)).createChooserIntent();
            startActivity(shareIntent);

            return true;
        }
    });

}

From source file:ch.ethz.coss.nervousnet.sample.SampleAppActivity.java

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

    // Set up action bar.
    final ActionBar actionBar = getActionBar();

    // Specify that the Home button should show an "Up" caret, indicating
    // that touching the
    // button will take the user one step up in the application's hierarchy.
    actionBar.setDisplayHomeAsUpEnabled(true);

    sapAdapter = new SampleAppPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager, attaching the adapter.
    vPager = (ViewPager) findViewById(R.id.pager);
    vPager.setAdapter(sapAdapter);//from ww  w  . j a  v a 2s.  c om

    if (mServiceConnection == null) {
        initConnection();
    }

    if (mService == null) {
        try {

            doBindService();
            Log.d("SampleAppActivity", bindFlag.toString()); // will
            // return
            // "true"
            if (!bindFlag) {

                Utils.displayAlert(SampleAppActivity.this, "Alert",
                        "Nervousnet HUB application is required to be installed and running to use this app. If not installed please download it from the App Store. If already installed, please turn on the Data Collection option inside the Nervousnet HUB application.",
                        "Download Now", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(
                                        "https://play.google.com/apps/testing/ch.ethz.coss.nervousnet.hub")));
                            }
                        }, "Exit", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                System.exit(0);
                            }
                        });
                Toast.makeText(SampleAppActivity.this,
                        "Please check if the Nervousnet HUB application is installed and running.",
                        Toast.LENGTH_SHORT).show();
            } else {
                startRepeatingTask();
                Toast.makeText(SampleAppActivity.this,
                        "Nervousnet Remote is running fine and startRepeatingTask() called", Toast.LENGTH_SHORT)
                        .show();

            }
        } catch (Exception e) {
            e.printStackTrace();
            Log.e("SensorDisplayActivity", "not able to bind ! ");
        }

        // //binding to remote service
        // boolean flag = bindService(it, mServiceConnection,
        // Service.BIND_AUTO_CREATE);
        //
        //

    }
}

From source file:gis.iwacu_new.rit.edu.main.swipetabs.SwipeCollectionActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_collection_demo);

    //parse the learning content needed for various tasks and settings
    try {//from   w  w  w .j  a v a2 s  .co  m
        //parse the XML learning content for display on the tabs
        //CHECK IF WE BE TOO MEMORY INTENSIVE - tried passing object
        //get the learning content from external storage, should be updated based on checks done when the app is opening
        File SDCardRoot = Environment.getExternalStorageDirectory();
        File IwacuDir = new File(SDCardRoot, getResources().getString((R.string.Iwacu_Directory)));
        File Learning_Content_File = new File(IwacuDir,
                getResources().getString((R.string.learning_file_name)));

        //http://developer.android.com/reference/java/io/FileInputStream.html
        InputStream in = new FileInputStream(Learning_Content_File);
        recor_doc = RecorDocument.parse(in);

        // Create an adapter that when requested, will return a fragment representing an object in
        // the collection.
        //
        // ViewPager and its adapters use support library fragments, so we must use
        // getSupportFragmentManager.
        mDemoCollectionPagerAdapter = new DemoCollectionPagerAdapter(getSupportFragmentManager());

        // Set up action bar.
        final ActionBar actionBar = getActionBar();

        // Specify that the Home button should show an "Up" caret, indicating that touching the
        // button will take the user one step up in the application's hierarchy.
        actionBar.setDisplayHomeAsUpEnabled(true);

        // Set up the ViewPager, attaching the adapter.
        mViewPager = (ViewPager) findViewById(R.id.pager);
        mViewPager.setAdapter(mDemoCollectionPagerAdapter);

    } catch (IOException e) {
        e.printStackTrace();
        TextView textView = new TextView(this);
        textView.setText(getResources().getText(R.string.error_loading_content));
        setContentView(textView);
    }
}