|
1 2 3 4 5 6 7 8 9 |
NSArray *keyArray; // Key Array NSArray *objectArray; // Objects Array keyArray = [NSArray arrayWithObjects:@"key1",@"key2",nil]; // Populating Keys array objectArray = [NSArray arrayWithObjects:@"object1",@"object2",nil]; // Populating Objects array NSDictionary *myDictionaryObject = [NSDictionary dictionaryWithObjects: objectArray forKeys: keyArray]; // Creating the dictionary object with objects the corresponding keys. |
Creating a NSDictionary Object With Multiple Objects and Keys
Tuesday, April 30th, 2013 at
10:27 am
Leave your comment
Simple Alert Dialog Popup with Title, Message, Icon and Button
Tuesday, April 30th, 2013 at
10:09 am
A quick a simple Alert Dialog Popup with Title, Message, Icon and Button
Don’t forget to import add the imports
import android.app.AlertDialog; import android.content.DialogInterface;
|
1 2 3 4 5 6 7 8 9 10 11 |
AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle("Title"); alertDialog.setMessage("Message"); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // TODO Add your code for the button here. } }); // Set the Icon for the Dialog alertDialog.setIcon(R.drawable.icon); alertDialog.show(); |
How to Execute Javascript in UIWebView?
Tuesday, April 30th, 2013 at
10:05 am
It is possible to execute javascript codes on the webpage loaded in a UIWebView. We can use stringByEvaluatingJavaScriptFromString: method of UIWebView object for this.
This method can be used once the url has been loaded in the web view as follows :
|
1 |
[webViewObj stringByEvaluatingJavaScriptFromString:@"Javascript code to be executed"]; // Here webViewObj is the UIWebView object. |
Android read phone(sim) number
Tuesday, April 30th, 2013 at
9:37 am
|
1 2 3 4 |
TelephonyManager telephoneMgr = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); String simNumber = telephoneMgr.getLine1Number(); you need to add ITelephony.aidl in your project.. |
Android alert view/pop up example
Tuesday, April 30th, 2013 at
9:35 am
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setTitle(mContext.getResources().getString(R.string.app_name)); builder.setIcon(R.drawable.ic_launcher); builder.setMessage("your message") .setCancelable(true) .setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); |
Programmatically create a password field
Tuesday, April 30th, 2013 at
9:33 am
|
1 2 3 4 5 6 |
EditText buddyPasswordEdtTxt = new EditText(mContext); buddyPasswordEdtTxt.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); buddyPasswordEdtTxt.setHint("password"); //buddyPasswordEdtTxt.setTransformationMethod(PasswordTransformationMethod.getInstance()); buddyPasswordEdtTxt.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); emailLayout.addView(buddyPasswordEdtTxt); |
Programmatically forward/stop forward calls in android device
Tuesday, April 30th, 2013 at
9:28 am
|
1 2 3 4 5 6 7 |
<strong>Forward calls</strong> Intent callIntent = new Intent(Intent.ACTION_CALL); String forwardNumber = "9999999999" String number = ("**21*"+forwardNumber+"#"); callIntent.setData(Uri.fromParts("tel", number, "#")); callIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(callIntent); |
|
1 2 3 4 5 6 |
Stop forwarding Intent callIntent = new Intent(Intent.ACTION_CALL); String number = "##21#"; callIntent.setData(Uri.fromParts("tel", number, "#")); callIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(callIntent); |
Shut down android device programmatically
Tuesday, April 30th, 2013 at
9:24 am
|
1 |
Runtime.getRuntime().exec(new String[]{ "su", "-c", "reboot -p" }); // you should have root access! |
Android – Restore layout after orientation change
Tuesday, April 30th, 2013 at
9:22 am
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
private static final String STATE_ACTIVE_POSITION = "context_position"; private static final String STATE_CONTENT_TEXT = "context_text"; //save context @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(STATE_ACTIVE_POSITION, mActivePosition); outState.putString(STATE_CONTENT_TEXT, mContentText); } //recall context @Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); mActivePosition = savedInstanceState.getInt(STATE_ACTIVE_POSITION); mContentText = savedInstanceState.getString(STATE_CONTENT_TEXT); //do your stuff here.... } |



