package pollfish.com.sampleproject;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import com.pollfish.interfaces.PollfishClosedListener;
import com.pollfish.interfaces.PollfishOpenedListener;
import com.pollfish.interfaces.PollfishSurveyCompletedListener;
import com.pollfish.interfaces.PollfishSurveyNotAvailableListener;
import com.pollfish.interfaces.PollfishSurveyReceivedListener;
import com.pollfish.interfaces.PollfishUserNotEligibleListener;
import com.pollfish.main.PollFish;
import com.pollfish.main.PollFish.ParamsBuilder;
import com.pollfish.constants.Position;
import theoremreach.com.theoremreach.TheoremReach;
import theoremreach.com.theoremreach.TheoremReachMomentListener;
import theoremreach.com.theoremreach.TheoremReachRewardListener;
import theoremreach.com.theoremreach.TheoremReachSurveyAvailableListener;
import theoremreach.com.theoremreach.TheoremReachSurveyListener;
public class IncentivizeActivity extends Activity implements
PollfishSurveyCompletedListener, PollfishOpenedListener,
PollfishClosedListener, PollfishSurveyReceivedListener,
PollfishSurveyNotAvailableListener, PollfishUserNotEligibleListener
{
SharedPreferences sharedpreferences;
private Button coinsBtn;
public static final String MyPREFERENCES = "myprefs";
public static final String value = "key";
//private TextView loggingTxt;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_incentivize);
TheoremReach.initWithApiKeyAndUserIdAndActivityContext("40xxxxxxxxxxxxxxxxxxxxxxxxxx", "ANDROID_TEST_ID", this);
//loggingTxt = (TextView) findViewById(R.id.logText);
TheoremReach.getInstance().setTheoremReachRewardListener(this);
TheoremReach.getInstance().setTheoremReachSurveyListener(this);
TheoremReach.getInstance().setTheoremReachSurveyAvailableListener(this);
TheoremReach.getInstance().setTheoremReachMomentListener(this);
coinsBtn = (Button) findViewById(R.id.coins_btn);
coinsBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (TheoremReach.getInstance().isSurveyAvailable()) {
TheoremReach.getInstance().showRewardCenter();
}
else
PollFish.show();
}
});
}
@Override
public void onPollfishClosed() {
Log.d("Pollfish", "onPollfishClosed");
}
@Override
public void onPollfishOpened() {
Log.d("Pollfish", "onPollfishOpened");
}
@Override
public void onPollfishSurveyNotAvailable() {
Log.d("Pollfish", "onPollfishSurveyNotAvailable");
runOnUiThread(new Runnable() {
@Override
public void run() {
//loggingTxt.setText(getString(R.string.not_available));
}
});
}
@Override
public void onUserNotEligible() {
Log.d("Pollfish", "onUserNotEligible");
runOnUiThread(new Runnable() {
@Override
public void run() {
//loggingTxt.setText(getString(R.string.user_not_eligible));
}
});
}
@Override
public void onResume() {
super.onResume();
Log.d("Pollfish", "onResume() ");
PollFish.ParamsBuilder paramsBuilder = new PollFish.ParamsBuilder("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
.indicatorPadding(5)
.customMode(true)
.build();
PollFish.initWith(this, paramsBuilder);
PollFish.hide();
//loggingTxt.setText(getString(R.string.logging));
coinsBtn.setVisibility(View.INVISIBLE);
}
@Override
public void onPollfishSurveyReceived(boolean playfulSurvey, int surveyPrice) {
Log.d("Pollfish", "onPollfishSurveyReceived(" + playfulSurvey + " , " + surveyPrice + ")");
runOnUiThread(new Runnable() {
@Override
public void run() {
coinsBtn.setVisibility(View.VISIBLE);
//loggingTxt.setText("Survey Received");
}
});
}
@Override
public void onPollfishSurveyCompleted(boolean playfulSurvey, int surveyPrice) {
Log.d("Pollfish", "onPollfishSurveyCompleted(" + playfulSurvey + " , " + surveyPrice + ")");
sharedpreferences = getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);
final int i = sharedpreferences.getInt(value, 0);
int count =i;
TextView tv_data = (TextView) findViewById(R.id.textView6);
tv_data.setText("Points : " +count);
SharedPreferences.Editor editor = sharedpreferences.edit();
count=count+10;
editor.putInt(value, count);
editor.apply();
runOnUiThread(new Runnable() {
@Override
public void run() {
coinsBtn.setVisibility(View.INVISIBLE);
//loggingTxt.setText(getString(R.string.survey_completed));
}
});
}
}
错误是多个dex文件定义Lcom / google / android / gms / internal / zzfe。
如果这个问题是在同一个项目中包含2个SDK的bcoz,我不知道。
gradle文件如下。
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "pollfish.com.sampleproject"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
}
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:design:26.+'
implementation 'com.google.android.gms:play-services-base:11.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
compile 'com.pollfish:pollfish:+:googleplayRelease@aar'
compile 'com.theoremreach:theoremreach:3.2.7'
compile 'com.google.android.gms:play-services-ads:10.2.1'
}