FilenameUtils
https://www.dropbox.com/s/fy21wu5nnesmms5/commons-io-2.5-bin.zip?dl=0
https://www.dropbox.com/s/fy21wu5nnesmms5/commons-io-2.5-bin.zip?dl=0
1 2 3 |
dependencies { compile files('libs/your jar file.jar') } |
1. Make sure you have picasso in your gradle build file’s dependencies tag.
1 2 |
<span class="pln">compile </span><span class="str">'com.squareup.picasso:picasso:2.5.2' </span> |
2. To use the Picasso for saving image file, you need to define a Target class. This method creates a target object that you can use with Picasso. Target is an interface defined in Picasso’s library. You can define this method […]
WebBrowser
1 2 |
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse()); startActivity(browserIntent); |
YouTube
1 2 3 4 5 6 7 |
// your video id // for instance a video link: http://www.youtube.com/watch?v=Q9hF0j9G8_M String videoId = "Q9hF0j9G8_M"; Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + videoId)); intent.putExtra("VIDEO_ID", videoId); startActivity(intent); |
1 |
String sPNotes = getPreferences(Context.MODE_PRIVATE).getString("NOTES", "EMPTY"); |
1 2 3 4 5 6 7 8 9 10 |
// 1. Called before Android kills an application, but doesn't protect you // if the user kills the app or restarts the device @Override protected void onSaveInstanceState(Bundle outState) { // Save the value in the EditText using the key NOTES outState.putString("NOTES","Your string"); super.onSaveInstanceState(outState); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
// 2. Will save key value pairs to SharedPreferences private void saveSettings(){ // SharedPreferences allow you to save data even if the user kills the app // MODE_PRIVATE : Preferences shared only by your app // MODE_WORLD_READABLE : All apps can read // MODE_WORLD_WRITABLE : All apps can write // edit() allows us to enter key vale pairs SharedPreferences.Editor sPEditor = getPreferences(Context.MODE_PRIVATE).edit(); // Add the key "NOTES" and assign it to the value sPEditor.putString("NOTES", notesEditText.getText().toString()); // Save the shared preferences sPEditor.commit(); } |
============================================= Setting values in Preference:
1 2 3 4 5 6 |
// MY_PREFS_NAME - a static String variable like: //public static final String MY_PREFS_NAME = "MyPrefsFile"; SharedPreferences.Editor editor = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE).edit(); editor.putString("name", "Elena"); editor.putInt("idName", 12); editor.commit(); |
Retrieve data from preference:
1 2 3 4 5 6 |
SharedPreferences prefs = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE); String restoredText = prefs.getString("text", null); if (restoredText != null) { String name = prefs.getString("name", "No name defined");//"No name defined" is the default value. int idName = prefs.getInt("idName", 0); //0 is the default value. } |
Android SharedPreferences in Fragment
1 2 |
// this = your fragment SharedPreferences preferences = this.getActivity().getSharedPreferences("pref", Context.MODE_PRIVATE); |
1 2 3 |
jQuery.validator.addMethod( "date", function( value, element ) { return this.optional( element ) || /^(19|20)\d{2}\/(0[1-9]|1[0-2])\/(0[1-9]|1\d|2\d|3[01])$/.test( value ); }, "Please enter date format eg.mm/dd/yyyy" ); |
PHP
1 2 3 4 5 6 7 8 9 10 11 |
<?php $line = "13/20/2017"; // perform a case-Insensitive search for the word "Vi" if (preg_match("/^(0[1-9]|1[0-2])\/(0[1-9]|1\d|2\d|3[01])\/(19|20)\d{2}$/", $line)) { print "Match found!"; }else{ print "No Match found!"; } ?> |
1 2 3 4 5 6 7 |
// your video id // for instance a video link: http://www.youtube.com/watch?v=Q9hF0j9G8_M String videoId = "Q9hF0j9G8_M"; Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + videoId)); intent.putExtra("VIDEO_ID", videoId); startActivity(intent); |
This is very simple to accomplish If you want to change it in code, call:
1 2 |
setTitle("My new title"); getActionBar().setIcon(R.drawable.my_icon); |
And set the values to whatever you please. Or, in the Android manifest XML file:
1 2 3 |
<activity android:name=".MyActivity" android:icon="@drawable/my_icon" android:label="My new title" /> |
To enable the back button in your app use:
1 2 |
getActionBar().setHomeButtonEnabled(true); getActionBar().setDisplayHomeAsUpEnabled(true); |
The code should all be placed in your onCreate so […]
Change it to :callIntent.setData(Uri.parse(“tel:”+phone_no)); and i didnt add this: callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Replace findViewById(R.id.includeCallEnd0) with findViewById(R.id.includeCallEnd0).findViewById(R.id.phoneEnd) and it should work because you want to set the click listener on the ImageButton and not the whole layout Use the following function to set the OnClickListener once:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
private static void applyListener(View child, OnClickListener listener) { if (child == null) return; if (child instanceof ViewGroup) { applyListener((ViewGroup) child, listener); } else if (child != null) { if(child.getId() == R.id.phoneEnd) { child.setOnClickListener(listener); } } } private static void applyListener(ViewGroup parent, OnClickListener listener) { for (int i = 0; i < parent.getChildCount(); i++) { View child = parent.getChildAt(i); if (child instanceof ViewGroup) { applyListener((ViewGroup) child, listener); } else { applyListener(child, listener); } } } |
Use applyListener(rootView, yourOnClickListener);