Thursday, November 13, 2014

Integration with skype or login with skype in anroid

hi friends
This is skype integration or login with skype
you have need to downloded skype app first then you can do this

this code will help u more thank you :-

activity.xml:-

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >
<TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="skype_intent_handler"
        android:textSize="18sp"
        android:textStyle="bold" />

    <EditText
        android:id="@+id/edt_skypeusername"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="15dp"
        android:ems="10"
        android:hint="Echo Testing skypeID - echo123" >
    </EditText>

    <Button
        android:id="@+id/openskype"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:text="Open Skype" />

    <Button
        android:id="@+id/skypemsg"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:text="Skype Message" />

    <Button
        android:id="@+id/skypecall"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:text="Skype Audio Call" />

    <Button
        android:id="@+id/skypevideocall"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:text="Skype Video Call" />

</LinearLayout>





.class file are as below:-


public class MainActivity extends  Activity {

Button openskype,skypemsg,skypecall,skypevideocall;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        openskype=(Button)findViewById(R.id.openskype);
        skypemsg=(Button)findViewById(R.id.skypemsg);
        skypecall=(Button)findViewById(R.id.skypecall);
        skypevideocall=(Button)findViewById(R.id.skypevideocall);
        
        
        
        
        
        
        openskype.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String mySkypeUri = "skype:";
   SkypeUri(MainActivity.this, mySkypeUri);
}
});
        
        
        skypemsg.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String skypeName = ((EditText) findViewById(R.id.edt_skypeusername)).getText().toString().trim();
   if(skypeName.length()<=0)
   {
    Toast.makeText(getApplicationContext(), "Please enter skype username to message", Toast.LENGTH_SHORT).show();
   }
   else
   {
    String mySkypeUri = "skype:"+skypeName+"?chat";
    SkypeUri(MainActivity.this, mySkypeUri);
   }
}
});
        
        
        
        
        skypecall.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String skypeName = ((EditText) findViewById(R.id.edt_skypeusername)).getText().toString().trim();
   if(skypeName.length()<=0)
   {
    Toast.makeText(getApplicationContext(), "Please enter skype username to call", Toast.LENGTH_SHORT).show();
   }
   else {
    String mySkypeUri = "skype:"+skypeName+"?call";
    SkypeUri(MainActivity.this, mySkypeUri);
   }   
}
});
        
        
        
        
        
        
        skypevideocall.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String skypeName = ((EditText) findViewById(R.id.edt_skypeusername)).getText().toString().trim();
   if(skypeName.length()<=0)
   {
    Toast.makeText(getApplicationContext(), "Please enter skype username to video call", Toast.LENGTH_SHORT).show();
   }
   else
   {
    String mySkypeUri = "skype:"+skypeName+"?call&video=true";
    SkypeUri(MainActivity.this, mySkypeUri);
   } 
}
});
         
    
    }
    
    public void SkypeUri(Context myContext, String mySkypeUri) {
      
     // Make sure the Skype for Android client is installed.
     if (!isSkypeClientInstalled(myContext)) {
      goToMarket(myContext);
      return;
     }
     Uri skypeUri = Uri.parse(mySkypeUri);
     Intent myIntent = new Intent(Intent.ACTION_VIEW, skypeUri);
     myIntent.setComponent(new ComponentName("com.skype.raider", "com.skype.raider.Main"));
     myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
     myContext.startActivity(myIntent);
     
     return;
    }
    public boolean isSkypeClientInstalled(Context myContext) {
     PackageManager myPackageMgr = myContext.getPackageManager();
     try {
      myPackageMgr.getPackageInfo("com.skype.raider", PackageManager.GET_ACTIVITIES);
     }
     catch (PackageManager.NameNotFoundException e) {
      return (false);
     }
     return (true);
    }
     
    /**
     * Install the Skype client through the market: URI scheme.
     */
     
    public void goToMarket(Context myContext) {
     Uri marketUri = Uri.parse("market://details?id=com.skype.raider");
     Intent myIntent = new Intent(Intent.ACTION_VIEW, marketUri);
     myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
     myContext.startActivity(myIntent);
     return;
    }
 }


manifest file are as below :-


    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" /> 


this will help you thank u friends ....

No comments:

Post a Comment