Skip to content

Commit

Permalink
Main: invote code via referrer attempt.
Browse files Browse the repository at this point in the history
  • Loading branch information
klauswuestefeld committed Sep 24, 2015
1 parent 36d0dba commit 0857092
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
6 changes: 6 additions & 0 deletions android/android.main/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />

<receiver android:name="sneer.android.ReferrerReceiver" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>

<receiver android:name="sneer.android.SneerBoot">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package sneer.android;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import sneer.android.ui.AcceptInviteActivity;

import static sneer.android.ui.AcceptInviteActivity.REFERRER_CODE;

public class ReferrerReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {

Bundle extras = intent.getExtras();
String referrerString = extras.getString("referrer");

Log.d(getClass().getName(), "Referrer is: " + referrerString);
Toast.makeText(context, "REFERRER: " + referrerString, Toast.LENGTH_LONG).show();

Intent accept = new Intent(context, AcceptInviteActivity.class);
accept.putExtra(REFERRER_CODE, referrerString);
context.startActivity(accept);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@

public class AcceptInviteActivity extends Activity {

private EditText nicknameEdit;
public static final String REFERRER_CODE = "REFERRER_CODE";

private EditText nicknameEdit;
private Button btnDone;

private String nickname;
Expand All @@ -33,7 +35,7 @@ public class AcceptInviteActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

inviteCode = getURIQuery(getIntent());
inviteCode = getInviteCode();

if (inviteCode == null) {
finishWith("Invalid Invite", this);
Expand All @@ -50,7 +52,14 @@ protected void onCreate(Bundle savedInstanceState) {
}});
}

private void obtainNickname() {
private String getInviteCode() {
String referrerCode = getIntent().getStringExtra(REFERRER_CODE);
return referrerCode != null
? referrerCode
: getURIQuery(getIntent());
}

private void obtainNickname() {
setContentView(R.layout.activity_add_contact);

nicknameEdit = (EditText) findViewById(R.id.nickname);
Expand Down

0 comments on commit 0857092

Please sign in to comment.