Android Open Source - CloudCopyPaster Net






From Project

Back to project page CloudCopyPaster.

License

The source code is released under:

Copyright (c) 2014, Dima Moiseev Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of s...

If you think the Android project CloudCopyPaster listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.newbilius.WinCopyPast;
/*from   w  w  w  .j  ava 2  s .com*/
import android.content.Context;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class Net {

    public String ErrorText="";

    public boolean Execute(String login,String pass,String pushId,Context context){
        boolean result=false;

        DefaultHttpClient httpclient=new DefaultHttpClient();

        HttpPost httppost = new HttpPost(Options.URL);

        List<NameValuePair> nameValuePairs = new ArrayList<>();
        nameValuePairs.add(new BasicNameValuePair("login", login));
        nameValuePairs.add(new BasicNameValuePair("pass", pass));
        nameValuePairs.add(new BasicNameValuePair("id", pushId));

        try {
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
            HttpResponse response = httpclient.execute(httppost);
            String resultString = EntityUtils.toString(response.getEntity());
            Log.Debug("response "+resultString);
            if (!resultString.contains("ERROR")){
                result=true;
            }else{
                if (resultString.contains("USER")){
                    ErrorText=context.getString(R.string.error_not_user);
                }else{
                    ErrorText=context.getString(R.string.error_net);
                }
            }
        } catch (IOException e) {
            Log.Error(e.getLocalizedMessage());
            e.printStackTrace();
        }

        return result;
    }
}




Java Source Code List

android.UnusedStub.java
com.newbilius.WinCopyPast.AboutActivity.java
com.newbilius.WinCopyPast.Analytics.java
com.newbilius.WinCopyPast.ConfigActivityController.java
com.newbilius.WinCopyPast.ConfigActivity.java
com.newbilius.WinCopyPast.GcmBroadcastReceiver.java
com.newbilius.WinCopyPast.GetTextToBufferReceiver.java
com.newbilius.WinCopyPast.Log.java
com.newbilius.WinCopyPast.Net.java
com.newbilius.WinCopyPast.OnComplete.java
com.newbilius.WinCopyPast.Options.java
com.newbilius.WinCopyPast.PushNotification.java