Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在应用程序中实现邀请链接功能的发送和检索_Android_Email_Invite - Fatal编程技术网

Android 在应用程序中实现邀请链接功能的发送和检索

Android 在应用程序中实现邀请链接功能的发送和检索,android,email,invite,Android,Email,Invite,我目前正在我的应用程序上尝试邀请其他人以来宾身份加入,以测试该应用程序。用户将输入客人的电子邮件地址,他们将收到一封电子邮件作为客人加入。由于某种原因,用户没有收到电子邮件 非常新的编程和android studio,所以有人可以帮助我。 我放了一张xml的图片,向您展示它的外观 问题中的代码中没有任何地方会发送电子邮件。请编辑您的问题,以包含更多的代码仍然缺少一些代码。。。。据我所知,您正在发送POST请求。这与发送电子邮件完全不同。您需要一个POP3或IMAP服务器来完成这项工作。好的,谢

我目前正在我的应用程序上尝试邀请其他人以来宾身份加入,以测试该应用程序。用户将输入客人的电子邮件地址,他们将收到一封电子邮件作为客人加入。由于某种原因,用户没有收到电子邮件

非常新的编程和android studio,所以有人可以帮助我。 我放了一张xml的图片,向您展示它的外观


问题中的代码中没有任何地方会发送电子邮件。请编辑您的问题,以包含更多的代码仍然缺少一些代码。。。。据我所知,您正在发送POST请求。这与发送电子邮件完全不同。您需要一个POP3或IMAP服务器来完成这项工作。好的,谢谢!看起来一切顺利,因为邀请成功了,但客人似乎没有收到电子邮件。当然,你的Android代码可以正常工作。问题是,当API发出请求时,它实际上可能没有发送消息。正如我所说的,这就是你在这个问题中缺少的代码。什么是https://“+BuildConfig.PORTAL_HOSTNAME+”/api3/im/%s/invite?是您的服务器,还是某个第三方API?这是一个url页面,来宾可以使用验证代码将自己邀请为来宾
public class ClientInfo extends AsyncTask<Void, Void, Void> {
    private static final String TAG = "ClientInfo";
    private static final String url = "https://"+ BuildConfig.PORTAL_HOSTNAME+"/api3/im/%s/invite";

    private final String emailaddress;
    private final Context context;
    private final String deviceId;

    public ClientInfo(Context context, String emailaddress) {
        this.deviceId = SaltIMApplication.getDeviceId(context);
        this.emailaddress = emailaddress;
        this.context = context;
    }

    protected String readResponse(HttpPost post) throws Exception {
        return Utils.readResponse(Utils.getHttpClient().execute(post));
    }

    protected Void doInBackground(Void... voids) {
        Log.i(TAG, "Invite ---- Send invite");
        String path = String.format(url, this.deviceId);
        String response = "";
        Log.i(TAG, "Invite ---- Path is:" + path);

        try {
            Log.i(TAG, "Invite ---- Post is: " + (Utils.createJsonPost(path, createBody())).toString());
            response = readResponse(Utils.createJsonPost(path, createBody()));
        } catch (Exception e) {
            Log.i(TAG, "Invite ---- Response from the invite - " + e.getMessage());
        }
        if (!response.equals("")) {
            try {
                JSONObject jsonObject = new JSONObject(response);
                String s = jsonObject.toString();
                Log.i(TAG, "Invite ---- Response: " + s);
            } catch (JSONException e) {
                Log.i(TAG, "Invite ---- Response: JSONException");
                e.printStackTrace();
            }
        }
        return null;
    }

    private StringEntity createBody() throws JSONException, UnsupportedEncodingException {


        JSONObject jsonRequest = new JSONObject();
        jsonRequest.put("email", emailaddress);
        jsonRequest.put("secret", BuildConfig.SHARED_SECRET);

        Log.i(TAG, "Invite ---- JsonObject is: " +jsonRequest);
        Log.i(TAG, "Invite ---- Sending invite");
        return new StringEntity(jsonRequest.toString());
    }
}
public class ClientInviteActivity extends AppCompatActivity {
    private static final String TAG = "ClientInviteActivity";

    @InjectView(R.id.enterEmail)
    EditText emailEntry;
    @InjectView(R.id.inviteButton)
    ImageButton inviteButton;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.client_invite);
        ButterKnife.inject(this);
        getSupportActionBar().setHomeButtonEnabled(true);
        getSupportActionBar().setTitle("Guest Invite");
    }

    @OnClick(R.id.inviteButton)

    public void onClick(){
        Log.i(TAG, "Invite - we are going to send an invite to " + emailEntry.getText().toString());
        String email = emailEntry.getText().toString();
        ClientInfo clientInfo = new ClientInfo(this, email);
        clientInfo.execute();

    }
}