welcome folks
FAQ in android,FAQ in dotnet,DotNet, C#,DOT NET CODE, ASP.NET, VB.NET, TRICKS,Dotnetcode,Android and Latest Technology Articles in VB,Android and ASP.NET

Friday, August 31, 2012

Difference Between Abstract Class & Interface in .net?

Abstract Classes:- 

-->abstrct methods means only method is defined.body undefined.(Not implented) just like skelton 

-->non-abstract methods means method body is defined 

just see below.. 

Sample_Parent is one class having 2 methods : 

1--method1()--this is abstract method 
2--method2()--this is non abstract method 

public abstract class Sample_Parent 

public void method1(); 

public void method2() 

// write code here 




the above clss having One abstract method is there,so should class is prefixed with One keyword 'abstract'.otherwise we wil get Compile time error. 

Abstarct class having Some are abstrct methods and some are non-abstrct methods. 

some People like this also Abstact class containg 0 or more number of Abstract methods!! 

Ex:HttpServlet. 

clear right now.. 

--> Now When we wil move For Abstract Class?? 

We have some of the Methods implementation we had..and we dont have some of the methods implementation 

so then this time we use Abstract classes.. 

Suppose i write one example on This situtation:- 

the above class is Abstart class we are unable to create the Object so we have to that abstrct method make it as a Non-abstrct method in Child class. 

Class Sample_child extends Sample_Parent 

public void method2() 

//write code here.. 

public static void main(String args[]) 

//here we have to create Child class object.. 




and illegal combination of abstarct: 

1.private--abstarct classes must inheritd.so the scope must public,default,protected. 
2.sealed Or Final--the abstarct methods are must ovvrride in child classes but final ignored inheritance concept. 
simply abstarct says am implementing in child clss but final is compltly Opposite. 
So these are Illegal combination. 
*************************************************************************************************** 


Now Waht Is Interface:- 

Interface is 100% Abstaract Methods(All are Need to Implement to Child Classes) 


in interface concept there is no chanse of Non-abstract methods. 

and similar to Abstarct classes we are unable to create Object to Interface. 

interface is a keyword.. 

am trying to write a Sample program on interface.. 

interface Sample 

public void Method1(); 
void method2(); 


above Sample is Interface having 2 methods..so thse are ready to implement to in child classes 


public class Sapmle_clss implements Sample 

public void method1() 

//write code here.. 



public void method2() 

//write code here.. 


public static void main(string ar[]) 

//here we have to create object to Class. 



We Dont have Any Implementaion so we move for Ineterface. 

Example: 
Any API's.. 

JDBC--Api relesed by Sun people 
implemnted by OraclePeople,mysql,DB2,etc. 

Servlet API--Relesed by Sun People Implemnetd By Apache,Weblogic, guys,,, 

in interface methods are By default:public, abstrct 
in interface Varibles are By default:public ,static, final 


Advantges Abstract class over Interface:- 

Multiple inheritance Concept not achiving through Abstract Classes 

But Through Interface We can Achive Multiple Inheritance 

How to send SMS to Multiple User in asp.net?

Please Refer the below links.

 http://www.codeproject.com/Articles/20064/How-to-Send-SMS-Messages-from-C-using-an-SQL-Datab

what is the uses of getElementById and ClientId In Asp.net

if (document.getElementById('<%=txtUserId.ClientId %>').value == "") { 
alert('Username is Mandtory'); 
return false; 


from your question 

<%=txtUserId.ClientId %> this statement is used to access server control ID in asp.net from javascript code & plz use this 
<%=txtUserId.ClientID %> 
in place of this <%=txtUserId.ClientId %> check difference

Wednesday, August 29, 2012

How to get Contact Number or list in android application?


There are three steps to this process.
1) Permissions
Add a permission to read contacts data to your application manifest.
<uses-permission android:name="android.permission.READ_CONTACTS"/>
2) Calling the Contact Picker
Within your Activity, create an Intent that asks the system to find an Activity that can perform a PICK action from the items in the Contacts URI.
Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
Call startActivityForResult, passing in this Intent (and a request code integer, PICK_CONTACT in this example). This will cause Android to launch an Activity that's registered to support ACTION_PICKon the People.CONTENT_URI, then return to this Activity when the selection is made (or canceled).
startActivityForResult(intent, PICK_CONTACT);
3) Listening for the Result
Also in your Activity, override the onActivityResult method to listen for the return from the 'select a contact' Activity you launched in step 2. You should check that the returned request code matches the value you're expecting, and that the result code is RESULT_OK.
You can get the URI of the selected contact by calling getData() on the data Intent parameter. To get the name of the selected contact you need to use that URI to create a new query and extract the name from the returned cursor.
@Override
public void onActivityResult(int reqCode, int resultCode, Intent data) {
  super.onActivityResult(reqCode, resultCode, data);

  switch (reqCode) {
    case (PICK_CONTACT) :
      if (resultCode == Activity.RESULT_OK) {
        Uri contactData = data.getData();
        Cursor c =  managedQuery(contactData, null, null, null, null);
        if (c.moveToFirst()) {
          String name = c.getString(c.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
          // TODO Whatever you want to do with the selected contact name.
        }
      }
      break;
  }
}

How to Close and Hide Android Soft KeyBoard?


You can force Android to hide the virtual keyboard using the InputMethodManager, callinghideSoftInputFromWindow, passing in the token of the window containing your edit field.
InputMethodManager imm = (InputMethodManager)getSystemService(
      Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);

How to declare global variable in android?


class MyApp extends Application {

  private String myState;

  public String getState(){
    return myState;
  }
  public void setState(String s){
    myState = s;
  }
}
class Blah extends Activity {

  @Override
  public void onCreate(Bundle b){
    ...
    MyApp appState = ((MyApp)getApplicationContext());
    String state = appState.getState();
    ...
  }
}

How to save Activity state in android?

You need to override onSaveInstanceState(Bundle savedInstanceState) and write the application state values you want to change to the Bundle parameter like this:


@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
  super.onSaveInstanceState(savedInstanceState);
  // Save UI state changes to the savedInstanceState.
  // This bundle will be passed to onCreate if the process is
  // killed and restarted.
  savedInstanceState.putBoolean("MyBoolean", true);
  savedInstanceState.putDouble("myDouble", 1.9);
  savedInstanceState.putInt("MyInt", 1);
  savedInstanceState.putString("MyString", "Welcome back to Android");
  // etc.
}
The Bundle is essentially a way of storing a NVP ("Name-Value Pair") map, and it will get passed in toonCreate and also onRestoreInstanceState where you'd extract the values like this:
@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
  super.onRestoreInstanceState(savedInstanceState);
  // Restore UI state from the savedInstanceState.
  // This bundle has also been passed to onCreate.
  boolean myBoolean = savedInstanceState.getBoolean("MyBoolean");
  double myDouble = savedInstanceState.getDouble("myDouble");
  int myInt = savedInstanceState.getInt("MyInt");
  String myString = savedInstanceState.getString("MyString");
}

Thursday, August 23, 2012

Difference between the px, dp, dip and sp used in Android?


px
Pixels - corresponds to actual pixels on the screen.
in
Inches - based on the physical size of the screen.
mm
Millimeters - based on the physical size of the screen.
pt
Points - 1/72 of an inch based on the physical size of the screen.
dp
Density-independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. Note: The compiler accepts both "dip" and "dp", though "dp" is more consistent with "sp".
·         If running on hdpi device 150x150 px image will take up 100*100 dp of screen space.
·         If running on mdpi device 150x150 px image will take up 150*150 dp of screen space.
·         If running on xhdpi device 150x150 px image will take up 75*75 dp of screen space.

sp
Scale-independent Pixels - this is like the dp unit, but it is also scaled by the user's font size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and user's preference.