List of usage examples for android.content Intent putExtras
public @NonNull Intent putExtras(@NonNull Bundle extras)
From source file:com.andybotting.tramhunter.activity.HomeActivity.java
private void goDefaultLaunchActivity() { Bundle extras = getIntent().getExtras(); boolean isNewIntentUUID = false; // Check to make sure we have not already used the UUID for a default // activity launch if (extras != null && extras.containsKey(TramHunter.KEY_PERFORM_DEFAULT_ACTIVITY_LAUNCH)) { String currentIntentUUID = extras.getString(TramHunter.KEY_PERFORM_DEFAULT_ACTIVITY_LAUNCH); isNewIntentUUID = !currentIntentUUID.equals(mLastUsedIntentUUID); mLastUsedIntentUUID = currentIntentUUID; }// w w w.ja v a 2 s . co m if (isNewIntentUUID) { String activityName = mPreferenceHelper.defaultLaunchActivity(); Intent intent = null; if (activityName.equals("HomeActivity")) { intent = null; } else if (activityName.equals("StopsListActivity")) { // Should be renamed to FavStopsListActivity, but causes a // problem on upgrade, so we'll just leave it startActivity(new Intent(this, FavouriteActivity.class)); } else if (activityName.equals("ClosestStopsListActivity")) { Favourite closestFavouriteStop = mFavouriteStopUtil.getClosestFavouriteStop(); if (closestFavouriteStop != null) { // Go to the closest favourite stop Bundle bundle = new Bundle(); bundle.putInt("tramTrackerId", closestFavouriteStop.getStop().getTramTrackerID()); if (closestFavouriteStop.getRoute() != null) bundle.putInt("routeId", closestFavouriteStop.getRoute().getId()); intent = new Intent(HomeActivity.this, StopDetailsActivity.class); intent.putExtras(bundle); } else { Toast.makeText(this, R.string.toast_unable_closest_stop, Toast.LENGTH_SHORT).show(); } } else if (activityName.equals("NearStopsActivity")) { startActivity(new Intent(this, NearStopsActivity.class)); } if (intent != null) startActivityForResult(intent, 1); } showMainHome(); }
From source file:com.irccloud.android.activity.LoginActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_RESOLVE_ERROR) { mResolvingError = false;//from www . ja v a 2 s .co m if (resultCode == RESULT_OK) { if (!mGoogleApiClient.isConnecting() && !mGoogleApiClient.isConnected()) { mGoogleApiClient.connect(); } } } else if (requestCode == REQUEST_RESOLVE_CREDENTIALS) { if (resultCode == RESULT_OK && data.hasExtra(Credential.EXTRA_KEY)) { Credential c = data.getParcelableExtra(Credential.EXTRA_KEY); name.setText(c.getName()); email.setText(c.getId()); password.setText(c.getPassword()); loading.setVisibility(View.GONE); login.setVisibility(View.VISIBLE); loginHintClickListener.onClick(null); new LoginTask().execute((Void) null); } else { loading.setVisibility(View.GONE); login.setVisibility(View.VISIBLE); } } else if (requestCode == REQUEST_RESOLVE_SAVE_CREDENTIALS) { if (resultCode == RESULT_OK) { Log.e("IRCCloud", "Credentials result: OK"); } Intent i = new Intent(LoginActivity.this, MainActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); if (getIntent() != null) { if (getIntent().getData() != null) i.setData(getIntent().getData()); if (getIntent().getExtras() != null) i.putExtras(getIntent().getExtras()); } startActivity(i); finish(); } }
From source file:RhodesService.java
public static void runApplication(String appName, Object params) { try {//from www . j ava 2 s . com Context ctx = RhodesService.getContext(); PackageManager mgr = ctx.getPackageManager(); PackageInfo info = mgr.getPackageInfo(appName, PackageManager.GET_ACTIVITIES); if (info.activities.length == 0) { Logger.E(TAG, "No activities found for application " + appName); return; } ActivityInfo ainfo = info.activities[0]; String className = ainfo.name; if (className.startsWith(".")) className = ainfo.packageName + className; Intent intent = new Intent(); intent.setClassName(appName, className); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (params != null) { Bundle startParams = new Bundle(); if (params instanceof String) { if (((String) params).length() != 0) { String[] paramStrings = ((String) params).split("&"); for (int i = 0; i < paramStrings.length; ++i) { String key = paramStrings[i]; String value = ""; int splitIdx = key.indexOf('='); if (splitIdx != -1) { value = key.substring(splitIdx + 1); key = key.substring(0, splitIdx); } startParams.putString(key, value); } } } else throw new IllegalArgumentException("Unknown type of incoming parameter"); intent.putExtras(startParams); } ctx.startActivity(intent); } catch (Exception e) { Logger.E(TAG, "Can't run application " + appName + ": " + e.getMessage()); } }
From source file:com.irccloud.android.activity.LoginActivity.java
private void login_or_connect() { if (NetworkConnection.IRCCLOUD_HOST != null && NetworkConnection.IRCCLOUD_HOST.length() > 0 && getIntent() != null && getIntent().getData() != null && getIntent().getData().getPath().endsWith("/access-link")) { NetworkConnection.getInstance().logout(); new AccessLinkTask().execute("https://" + NetworkConnection.IRCCLOUD_HOST + "/chat/access-link?" + getIntent().getData().getEncodedQuery().replace("&mobile=1", "") + "&format=json"); setIntent(new Intent(this, LoginActivity.class)); } else if (getIntent() != null && getIntent().getData() != null && getIntent().getData().getHost().equals("referral")) { new ImpressionTask().execute(getIntent().getDataString().substring( getIntent().getData().getScheme().length() + getIntent().getData().getHost().length() + 4)); if (getSharedPreferences("prefs", 0).contains("session_key")) { Intent i = new Intent(LoginActivity.this, MainActivity.class); startActivity(i);/* w w w . ja va 2s .c o m*/ finish(); } } else if (getSharedPreferences("prefs", 0).contains("session_key")) { Intent i = new Intent(LoginActivity.this, MainActivity.class); if (getIntent() != null) { if (getIntent().getData() != null) i.setData(getIntent().getData()); if (getIntent().getExtras() != null) i.putExtras(getIntent().getExtras()); } startActivity(i); finish(); } else { if (host.getVisibility() == View.GONE && mGoogleApiClient.isConnected()) { Log.e("IRCCloud", "Play Services connected"); CredentialRequest request = new CredentialRequest.Builder() .setAccountTypes("https://" + NetworkConnection.IRCCLOUD_HOST) .setSupportsPasswordLogin(true).build(); Auth.CredentialsApi.request(mGoogleApiClient, request) .setResultCallback(new ResultCallback<CredentialRequestResult>() { @Override public void onResult(CredentialRequestResult result) { if (result.getStatus().isSuccess()) { Log.e("IRCCloud", "Credentials request succeeded"); email.setText(result.getCredential().getId()); password.setText(result.getCredential().getPassword()); loginHintClickListener.onClick(null); new LoginTask().execute((Void) null); } else if (result.getStatus() .getStatusCode() == CommonStatusCodes.SIGN_IN_REQUIRED) { Log.e("IRCCloud", "Credentials request sign in"); loading.setVisibility(View.GONE); connecting.setVisibility(View.GONE); login.setVisibility(View.VISIBLE); } else if (result.getStatus().hasResolution()) { Log.e("IRCCloud", "Credentials request requires resolution"); try { startIntentSenderForResult( result.getStatus().getResolution().getIntentSender(), REQUEST_RESOLVE_CREDENTIALS, null, 0, 0, 0); } catch (IntentSender.SendIntentException e) { e.printStackTrace(); loading.setVisibility(View.GONE); connecting.setVisibility(View.GONE); login.setVisibility(View.VISIBLE); } } else { Log.e("IRCCloud", "Credentials request failed"); loading.setVisibility(View.GONE); connecting.setVisibility(View.GONE); login.setVisibility(View.VISIBLE); } } }); } else { loading.setVisibility(View.GONE); connecting.setVisibility(View.GONE); login.setVisibility(View.VISIBLE); } } }
From source file:cn.zsmy.akm.doctor.profile.fragment.UploadPhotoFragment.java
@Override public void onClick(View v) { String type = null;/*from w ww. j a v a 2s . co m*/ switch (v.getId()) { case R.id.privous: if (getActivity() instanceof ToLicense) { ((ToLicense) getActivity()).toIntroduction(); } break; case R.id.next: if (getActivity() instanceof ToLicense) { ((ToLicense) getActivity()).toLicense(); } break; case R.id.image_submit_one: if (dataEntity.getDoctorAuth() != null) { for (int i = 0; i < dataEntity.getDoctorAuth().size(); i++) { if (dataEntity.getDoctorAuth().get(i) != null && dataEntity.getDoctorAuth().get(i).getStatus() != null && dataEntity.getDoctorAuth().get(i).getZType() != null && dataEntity.getDoctorAuth().get(i).getZType().equals("4")) { type = dataEntity.getDoctorAuth().get(i).getStatus(); } } } if (type == null) { type = "0"; } if (!getClickRemind(0, type)) { } else { loadImage(urlDatas.get(0)); } break; case R.id.vedio_submit_two: if (dataEntity.getDoctorAuth() != null) { for (int i = 0; i < dataEntity.getDoctorAuth().size(); i++) { if (dataEntity.getDoctorAuth().get(i) != null && dataEntity.getDoctorAuth().get(i).getStatus() != null && dataEntity.getDoctorAuth().get(i).getZType() != null && dataEntity.getDoctorAuth().get(i).getZType().equals("5")) { type = dataEntity.getDoctorAuth().get(i).getStatus(); } } } if (type == null) { type = "0"; } if (!getClickRemind(1, type)) { } else { loadVideo(urlDatas.get(1)); } break; case R.id.load_your_image: PIC = DOCTOR_IMAGE_PIC; photoPopupWindow = new PhotoPopupWindow(getActivity()); photoPopupWindow.setItemText("?", ""); photoPopupWindow.setItemClickListener(this); photoPopupWindow.showPopupWindow(); break; case R.id.load_your_video: PIC = DOCTOR_VIDEO; if (VideoRecordActivity.uri == null) { try { // Intent intent = new Intent(getActivity(), RecordingActivity.class); Intent intent = new Intent(getActivity(), VideoRecordActivity.class); intent.putExtra("CONTEXT", Constants.UPLOAD_RECORD_VALUES); startActivityForResult(intent, PIC); WHETHER_FROM_ACTIVITY_BACK = true; } catch (Exception e) { e.printStackTrace(); } } else { // // Intent intent = new Intent(Intent.ACTION_VIEW); // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // intent.setDataAndType(Uri.fromFile(new File(VideoRecordActivity.uri)), "video/*"); // startActivity(intent); Intent intent = new Intent(getActivity(), PreviewActivity.class); Bundle bundle = new Bundle(); bundle.putString("video", VideoRecordActivity.uri); intent.putExtras(bundle); startActivity(intent); } break; } }
From source file:com.door43.translationstudio.ui.dialogs.BackupDialog.java
private void doSelectDestinationFolder(boolean usfmOutput) { String typeStr = null;/* w w w.j a v a 2s . co m*/ Intent intent = new Intent(getActivity(), FileChooserActivity.class); isOutputToDocumentFile = SdUtils.isSdCardPresentLollipop(); if (isOutputToDocumentFile) { typeStr = FileChooserActivity.SD_CARD_TYPE; } else { typeStr = FileChooserActivity.INTERNAL_TYPE; } intent.setType(typeStr); Bundle args = new Bundle(); args.putString(FileChooserActivity.EXTRA_MODE, FileChooserActivity.SelectionMode.DIRECTORY.name()); args.putString(FileChooserActivity.EXTRA_TITLE, getActivity().getResources().getString(R.string.choose_destination_folder)); args.putBoolean(EXTRA_OUTPUT_TO_USFM, usfmOutput); intent.putExtras(args); startActivityForResult(intent, SELECT_EXPORT_FOLDER_REQUEST); }
From source file:com.andryr.musicplayer.PlaybackService.java
private void notifyChange(String what) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { updateMediaSession(what);/* w w w. ja va 2s . c o m*/ } saveState(QUEUE_CHANGED.equals(what) || ITEM_ADDED.equals(what) || ORDER_CHANGED.equals(what)); if (PLAYSTATE_CHANGED.equals(what) || META_CHANGED.equals(what)) { Notification.updateNotification(this); // notify third party applications Intent intent = new Intent(); intent.setAction( "com.android.music." + (PLAYSTATE_CHANGED.equals(what) ? "playstatechanged" : "metachanged")); Bundle bundle = new Bundle(); // put the song's metadata bundle.putString("track", getSongTitle()); bundle.putString("artist", getArtistName()); bundle.putString("album", getAlbumName()); // put the song's total duration (in ms) bundle.putLong("duration", getTrackDuration()); // put the song's current position bundle.putLong("position", getPlayerPosition()); // put the playback status bundle.putBoolean("playing", isPlaying()); // currently playing // put your application's package bundle.putString("scrobbling_source", getPackageName()); intent.putExtras(bundle); sendBroadcast(intent); } sendBroadcast(what, null); }
From source file:com.android.music.AlbumBrowserFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { switch (item.getItemId()) { case PLAY_SELECTION: { // play the selected album long[] list = MusicUtils.getSongListForAlbum(getActivity(), Long.parseLong(mCurrentAlbumId)); MusicUtils.playAll(getActivity(), list, 0); return true; }// ww w. ja v a2s. c om case QUEUE: { long[] list = MusicUtils.getSongListForAlbum(getActivity(), Long.parseLong(mCurrentAlbumId)); MusicUtils.addToCurrentPlaylist(getActivity(), list); return true; } case NEW_PLAYLIST: { Intent intent = new Intent(); intent.setClass(getActivity(), CreatePlaylist.class); startActivityForResult(intent, NEW_PLAYLIST); return true; } case PLAYLIST_SELECTED: { long[] list = MusicUtils.getSongListForAlbum(getActivity(), Long.parseLong(mCurrentAlbumId)); long playlist = item.getIntent().getLongExtra("playlist", 0); MusicUtils.addToPlaylist(getActivity(), list, playlist); return true; } case DELETE_ITEM: { long[] list = MusicUtils.getSongListForAlbum(getActivity(), Long.parseLong(mCurrentAlbumId)); String f; if (android.os.Environment.isExternalStorageRemovable()) { f = getString(R.string.delete_album_desc); } else { f = getString(R.string.delete_album_desc_nosdcard); } String desc = String.format(f, mCurrentAlbumName); Bundle b = new Bundle(); b.putString("description", desc); b.putLongArray("items", list); Intent intent = new Intent(); intent.setClass(getActivity(), DeleteItems.class); intent.putExtras(b); startActivityForResult(intent, -1); return true; } case SEARCH: doSearch(); return true; } return super.onContextItemSelected(item); }
From source file:com.android.music.AlbumBrowserActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { badSymptoms.saveMenu("popup", item.toString()); switch (item.getItemId()) { case PLAY_SELECTION: { // play the selected album long[] list = MusicUtils.getSongListForAlbum(this, Long.parseLong(mCurrentAlbumId)); MusicUtils.playAll(this, list, 0); return true; }//from w ww .j a v a 2s.c o m case QUEUE: { long[] list = MusicUtils.getSongListForAlbum(this, Long.parseLong(mCurrentAlbumId)); MusicUtils.addToCurrentPlaylist(this, list); return true; } case NEW_PLAYLIST: { Intent intent = new Intent(); intent.setClass(this, CreatePlaylist.class); startActivityForResult(intent, NEW_PLAYLIST); return true; } case PLAYLIST_SELECTED: { long[] list = MusicUtils.getSongListForAlbum(this, Long.parseLong(mCurrentAlbumId)); long playlist = item.getIntent().getLongExtra("playlist", 0); MusicUtils.addToPlaylist(this, list, playlist); return true; } case DELETE_ITEM: { long[] list = MusicUtils.getSongListForAlbum(this, Long.parseLong(mCurrentAlbumId)); String f; if (android.os.Environment.isExternalStorageRemovable()) { f = getString(R.string.delete_album_desc); } else { f = getString(R.string.delete_album_desc_nosdcard); } String desc = String.format(f, mCurrentAlbumName); Bundle b = new Bundle(); b.putString("description", desc); b.putLongArray("items", list); Intent intent = new Intent(); intent.setClass(this, DeleteItems.class); intent.putExtras(b); startActivityForResult(intent, -1); return true; } case SEARCH: doSearch(); return true; } return super.onContextItemSelected(item); }
From source file:org.ednovo.goorusearchwidget.ResourcePlayer.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); dialog = new ProgressDialog(this); prefsPrivate = getSharedPreferences(PREFS_PRIVATE, Context.MODE_PRIVATE); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); setContentViewLayout = new RelativeLayout(ResourcePlayer.this); prefsPrivate = getSharedPreferences(PREFS_PRIVATE, Context.MODE_PRIVATE); token = prefsPrivate.getString("token", ""); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); Bundle extra = getIntent().getExtras(); if (extra != null) { value = extra.getInt("key"); gooruOID1 = extra.getStringArrayList("goor"); searchkeyword = extra.getString("searchkey"); limit = gooruOID1.size();// w ww .j a v a 2 s . com gooruOID = gooruOID1.get(value); resourceGooruId = gooruOID; if (!gooruOID.isEmpty() || !gooruOID.equalsIgnoreCase("") || gooruOID != null) { if (checkInternetConnection()) { dialog = new ProgressDialog(ResourcePlayer.this); dialog.setTitle("gooru"); dialog.setMessage("Please wait while loading..."); dialog.setCancelable(false); dialog.show(); new getResourcesInfo().execute(); } else { dialog = new ProgressDialog(ResourcePlayer.this); dialog.setTitle("gooru"); dialog.setMessage("No internet connection"); dialog.show(); } } } Editor prefsPrivateEditor = prefsPrivate.edit(); // Authentication details prefsPrivateEditor.putString("searchkeyword", searchkeyword); prefsPrivateEditor.commit(); wvPlayer = new WebView(ResourcePlayer.this); wvPlayer.resumeTimers(); wvPlayer.getSettings().setJavaScriptEnabled(true); wvPlayer.getSettings().setPluginState(PluginState.ON); wvPlayer.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); wvPlayer.setWebViewClient(new HelloWebViewClient()); wvPlayer.setWebChromeClient(new MyWebChromeClient() { }); wvPlayer.getSettings().setPluginsEnabled(true); new getResourcesInfo().execute(); RelativeLayout temp = new RelativeLayout(ResourcePlayer.this); temp.setId(668); temp.setBackgroundColor(getResources().getColor(android.R.color.transparent)); header = new RelativeLayout(ResourcePlayer.this); header.setId(1); header.setBackgroundDrawable(getResources().getDrawable(R.drawable.navbar)); RelativeLayout.LayoutParams headerParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, 53); headerParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1); headerParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, -1); ivCloseIcon = new ImageView(ResourcePlayer.this); ivCloseIcon.setId(130); ivCloseIcon.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams ivCloseIconIconParams = new RelativeLayout.LayoutParams(50, 50); ivCloseIconIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); ivCloseIconIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 1); ivCloseIcon.setPadding(0, 0, 0, 0); ivCloseIcon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); ivCloseIcon.setBackgroundDrawable(getResources().getDrawable(R.drawable.close_corner)); header.addView(ivCloseIcon, ivCloseIconIconParams); ivmoveforward = new ImageView(ResourcePlayer.this); ivmoveforward.setId(222); if (value == limit - 1) { ivmoveforward.setVisibility(View.GONE); } ivmoveforward.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams ivmoveforwardIconIconParams = new RelativeLayout.LayoutParams(21, 38); ivmoveforwardIconIconParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, -1); ivmoveforwardIconIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); ivmoveforwardIconIconParams.setMargins(0, 0, 30, 0); imageshare = new ImageView(ResourcePlayer.this); imageshare.setId(440); imageshare.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams imageshareIconParams = new RelativeLayout.LayoutParams(50, 50); imageshareIconParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, -1); imageshareIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); imageshareIconParams.setMargins(0, 10, 100, 0); tvDescriptionn = new TextView(ResourcePlayer.this); tvDescriptionn1 = new TextView(ResourcePlayer.this); edittext_copyurl = new EditText(ResourcePlayer.this); imageshare.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (desc == 0) { new getShortUrl().execute(); imageshare.setBackgroundDrawable(getResources().getDrawable(R.drawable.share_selected)); subheader.setVisibility(View.VISIBLE); subheader.removeAllViews(); tvDescriptionn.setVisibility(View.VISIBLE); tvDescriptionn1.setVisibility(View.VISIBLE); edittext_copyurl.setVisibility(View.VISIBLE); tvDescriptionn.setText("Share this with other by copying and pasting these links"); tvDescriptionn.setId(221); tvDescriptionn.setTextSize(18); tvDescriptionn.setTypeface(null, Typeface.BOLD); tvDescriptionn.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvDescriptionParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvDescriptionParams.setMargins(20, 10, 0, 20); subheader.addView(tvDescriptionn, tvDescriptionParams); tvDescriptionn1.setText("Collections"); tvDescriptionn1.setId(226); tvDescriptionn1.setTextSize(18); tvDescriptionn1.setTypeface(null, Typeface.BOLD); tvDescriptionn1.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvDescriptionParams1 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvDescriptionParams1.setMargins(20, 42, 0, 20); subheader.addView(tvDescriptionn1, tvDescriptionParams1); edittext_copyurl.setId(266); edittext_copyurl.setTextSize(18); edittext_copyurl.setTypeface(null, Typeface.BOLD); edittext_copyurl.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvDescriptionParams11 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvDescriptionParams11.setMargins(130, 35, 0, 20); subheader.addView(edittext_copyurl, tvDescriptionParams11); desc = 1; flag = 0; } else { imageshare.setBackgroundDrawable(getResources().getDrawable(R.drawable.share_normal)); subheader.removeAllViews(); subheader.setVisibility(View.GONE); desc = 0; } } }); imageshare.setBackgroundDrawable(getResources().getDrawable(R.drawable.share_normal)); ivmoveforward.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (value < limit - 1) { Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class); Bundle extras = new Bundle(); // extras.putString("gooruOId",s); extras.putStringArrayList("goor", gooruOID1); value++; extras.putInt("key", value); intentResPlayer.putExtras(extras); urlcheck = 0; finish(); startActivity(intentResPlayer); } } }); ivmoveforward.setBackgroundDrawable(getResources().getDrawable(R.drawable.arrowright)); ivmoveback = new ImageView(ResourcePlayer.this); ivmoveback.setId(220); if (value == 0) { ivmoveback.setVisibility(View.GONE); } ivmoveback.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams ivmovebackIconIconParams = new RelativeLayout.LayoutParams(21, 38); ivmovebackIconIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1); ivmovebackIconIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); ivmovebackIconIconParams.setMargins(55, 0, 0, 0); ivmoveback.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!(value <= 0)) { value--; Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class); Bundle extras = new Bundle(); extras.putStringArrayList("goor", gooruOID1); extras.putInt("key", value); intentResPlayer.putExtras(extras); urlcheck = 0; finish(); startActivity(intentResPlayer); } } }); ivmoveback.setBackgroundDrawable(getResources().getDrawable(R.drawable.left)); webViewBack = new ImageView(ResourcePlayer.this); webViewBack.setId(323); webViewBack.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams webViewBackIconParams = new RelativeLayout.LayoutParams(25, 26); webViewBackIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1); webViewBackIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); webViewBackIconParams.setMargins(175, 0, 0, 0); webViewBack.setBackgroundDrawable(getResources().getDrawable(R.drawable.arrow_leftactive)); webViewBack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (wvPlayer.canGoBack()) { wvPlayer.goBack(); } } }); webViewRefresh = new ImageView(ResourcePlayer.this); webViewRefresh.setId(322); webViewRefresh.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams webViewRefreshIconParams = new RelativeLayout.LayoutParams(30, 30); webViewRefreshIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1); webViewRefreshIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); webViewRefreshIconParams.setMargins(305, 0, 0, 0); webViewRefresh.setBackgroundDrawable(getResources().getDrawable(R.drawable.refresh)); webViewRefresh.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { wvPlayer.reload(); } }); webViewForward = new ImageView(ResourcePlayer.this); webViewForward.setId(321); webViewForward.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams webViewForwardIconParams = new RelativeLayout.LayoutParams(25, 26); webViewForwardIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1); webViewForwardIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); webViewForwardIconParams.setMargins(245, 0, 0, 0); webViewForward.setBackgroundDrawable(getResources().getDrawable(R.drawable.arrow_rightactive)); webViewForward.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (wvPlayer.canGoForward()) { wvPlayer.goForward(); } } }); ivResourceIcon = new ImageView(ResourcePlayer.this); ivResourceIcon.setId(30); ivResourceIcon.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams ivResourceIconParams = new RelativeLayout.LayoutParams(50, 25); ivResourceIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); ivResourceIconParams.addRule(RelativeLayout.LEFT_OF, 130); ivResourceIcon.setPadding(50, 0, 0, 0); ivResourceIcon.setBackgroundDrawable(getResources().getDrawable(R.drawable.handouts)); header.addView(ivResourceIcon, ivResourceIconParams); tvLearn = new TextView(this); tvLearn.setText("Learn More"); tvLearn.setId(20); tvLearn.setPadding(100, 0, 0, 0); tvLearn.setTextSize(20); tvLearn.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvLearnParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvLearnParams.addRule(RelativeLayout.CENTER_VERTICAL, 1); tvLearnParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 1); tvAbout = new ImageView(ResourcePlayer.this); tvAbout.setId(21); tvAbout.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams webViewForwardIconParamsa = new RelativeLayout.LayoutParams(32, 32); webViewForwardIconParamsa.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, -1); webViewForwardIconParamsa.addRule(RelativeLayout.CENTER_VERTICAL, -1); webViewForwardIconParamsa.setMargins(0, 0, 200, 0); tvAbout.setBackgroundDrawable(getResources().getDrawable(R.drawable.info)); header.addView(tvAbout, webViewForwardIconParamsa); RelativeLayout fortvtitle = new RelativeLayout(this); RelativeLayout.LayoutParams tvTitleParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvTitleParams.addRule(RelativeLayout.CENTER_HORIZONTAL, 1); tvTitleParams.addRule(RelativeLayout.CENTER_VERTICAL, 1); tvTitleParams.addRule(RelativeLayout.RIGHT_OF, 322); tvTitleParams.addRule(RelativeLayout.LEFT_OF, 21); header.addView(fortvtitle, tvTitleParams); tvTitle = new TextView(this); tvTitle.setText(""); tvTitle.setId(22); tvTitle.setPadding(0, 0, 0, 0); tvTitle.setTextSize(25); tvTitle.setSingleLine(true); tvTitle.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvTitleParamstv = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvTitleParamstv.addRule(RelativeLayout.CENTER_HORIZONTAL, 1); tvTitleParamstv.addRule(RelativeLayout.CENTER_VERTICAL, 1); fortvtitle.addView(tvTitle, tvTitleParamstv); tvViewsNLikes = new TextView(this); tvViewsNLikes.setText(""); tvViewsNLikes.setId(23); tvViewsNLikes.setPadding(0, 0, 5, 5); tvViewsNLikes.setTextSize(18); tvViewsNLikes.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvViewsNLikesParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvViewsNLikesParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 1); tvViewsNLikesParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1); subheader = new RelativeLayout(ResourcePlayer.this); subheader.setId(100); subheader.setVisibility(View.GONE); subheader.setBackgroundDrawable(getResources().getDrawable(R.drawable.navbar)); RelativeLayout.LayoutParams subheaderParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, 100); subheaderParams.addRule(RelativeLayout.BELOW, 1); subheaderParams.addRule(RelativeLayout.CENTER_IN_PARENT, 1); RelativeLayout.LayoutParams wvPlayerParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); wvPlayerParams.addRule(RelativeLayout.BELOW, 100); wvPlayerParams.addRule(RelativeLayout.CENTER_IN_PARENT, 100); LinearLayout videoLayout = new LinearLayout(this); videoLayout.setVisibility(View.GONE); header.addView(webViewBack, webViewBackIconParams); header.addView(webViewRefresh, webViewRefreshIconParams); header.addView(webViewForward, webViewForwardIconParams); header.addView(ivmoveforward, ivmoveforwardIconIconParams); header.addView(imageshare, imageshareIconParams); header.addView(ivmoveback, ivmovebackIconIconParams); temp.addView(header, headerParams); temp.addView(subheader, subheaderParams); temp.addView(wvPlayer, wvPlayerParams); temp.addView(videoLayout, wvPlayerParams); setContentViewLayout.addView(temp, layoutParams); setContentView(setContentViewLayout); tvDescription = new TextView(ResourcePlayer.this); tvDescription1 = new TextView(ResourcePlayer.this); tvAbout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (flag == 0) { subheader.setVisibility(View.VISIBLE); subheader.removeAllViews(); // tvDescriptionn.setVisibility(View.INVISIBLE); tvDescription1.setVisibility(View.VISIBLE); tvDescription.setVisibility(View.VISIBLE); tvDescription.setText("Description"); tvDescription.setId(221); tvDescription.setTextSize(18); tvDescription.setTypeface(null, Typeface.BOLD); tvDescription.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvDescriptionParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvDescriptionParams.setMargins(20, 10, 0, 20); tvDescriptionParams.addRule(RelativeLayout.BELOW, 220); tvDescription1.setText(description); tvDescription1.setLines(3); tvDescription1.setId(321); tvDescription1.setTextSize(15); tvDescription1.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvDescription1Params = new RelativeLayout.LayoutParams(1100, 100); tvDescription1Params.addRule(RelativeLayout.CENTER_IN_PARENT, -1); tvDescription1.setPadding(100, 20, 100, 0); subheader.addView(tvDescription1, tvDescription1Params); desc = 0; flag = 1; flag1 = 0; } else { subheader.removeAllViews(); subheader.setVisibility(View.GONE); flag = 0; } } }); }