我目前正在使用PHP将数据从我的CRM添加到SQL数据库。当我将数据添加到数据库时,我希望它将数据库中创建的记录的ID返回给CRM。如果我能得到响应,我可以将详细信息发送回CRM,我只需要知道如何在创建记录时获取记录ID。这是我目前的代码:
public class book extends AppCompatActivity {
private String extra;
private WebView webView;
private TextView textView;
private Intent intent;
private LinearLayout Linear1;
private RelativeLayout Relative1;
private int colorId;
private LayoutInflater inflater;
private View layout;
private TextView text;
private Toast toast;
public int flag;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_book);
textView = (TextView)findViewById(R.id.textView3);
webView = (WebView)this.findViewById(R.id.webView);
Linear1 = (LinearLayout)findViewById(R.id.Linear1);
Relative1 = (RelativeLayout)findViewById(R.id.Relative1);
Typeface face = Typeface.createFromAsset(getAssets(),
"fonts/arabicfont.otf");
textView.setTypeface(face);
intent = getIntent();
colorId = intent.getIntExtra("COLOR_EXTRA", colorId);
Linear1.setBackgroundResource(colorId);
Relative1.setBackgroundResource(colorId);
String chapterPos = intent.getExtras().getString("EXTRA");
doItNow(chapterPos);
webView.setWebViewClient(new WebViewClient(){
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
String scrollPos = intent.getExtras().getString("SCROLL");
Toast.makeText(book.this, scrollPos, Toast.LENGTH_SHORT).show();
float webviewsize = webView.getContentHeight() - webView.getTop();
float positionInWV = webviewsize * (Float.parseFloat(scrollPos));
int positionY = Math.round(webView.getTop() + positionInWV);
webView.scrollTo(0, positionY);
}
}
);
}
public void sectionsFnc(View view) {
Intent intent = new Intent(book.this, storyZero.class);
intent.putExtra("COLOR_EXTRA", colorId);
startActivity(intent);
}
public void backFunc(View view) {
Intent intent = new Intent(book.this, FirstScreen.class);
startActivity(intent);
}
public void nextStory(View view) {
int iExtra = Integer.parseInt(extra) + 1;
if(iExtra<=10) {
extra = String.valueOf(iExtra);
doItNow(extra);
} else {
inflater = getLayoutInflater();
layout = inflater.inflate(R.layout.toast,
(ViewGroup) findViewById(R.id.toast_root));
text = (TextView) layout.findViewById(R.id.text);
text.setText("لقد وصلت لنهاية الكتاب!");
toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(Toast.LENGTH_SHORT);
toast.setView(layout);
toast.show();
}
}
public void preStory(View view) {
int iExtra = Integer.parseInt(extra) - 1;
if(iExtra>=0) {
extra = String.valueOf(iExtra);
doItNow(extra);
} else {
inflater = getLayoutInflater();
layout = inflater.inflate(R.layout.toast,
(ViewGroup) findViewById(R.id.toast_root));
text = (TextView) layout.findViewById(R.id.text);
text.setText("أنت في بداية الكتاب!");
toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(Toast.LENGTH_SHORT);
toast.setView(layout);
toast.show();
}
}
private float calculateProgression(WebView content) {
float positionTopView = content.getTop();
float contentHeight = content.getContentHeight();
float currentScrollPosition = content.getScrollY();
float percentWebview = (currentScrollPosition - positionTopView) / contentHeight;
return percentWebview;
}
@Override
protected void onStop() {
float position = calculateProgression(webView);
SharedPreferences sharePref = getSharedPreferences("webviewScroll", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharePref.edit();
editor.putFloat("SCROLLPOS", position);
editor.putInt("CHAPTER", flag);
editor.commit();
super.onStop();
}
public void doItNow(String mExtra) {
extra = mExtra;
if(extra.equals("0")) {
webView.loadUrl("file:///android_asset/1.htm");
flag = 0;
} else if(extra.equals("1")) {
webView.loadUrl("file:///android_asset/2.htm");
flag = 1;
} else if(extra.equals("2")) {
webView.loadUrl("file:///android_asset/3.htm");
flag = 2;
} else if(extra.equals("3")) {
webView.loadUrl("file:///android_asset/4.htm");
flag = 3;
} else if(extra.equals("4")) {
webView.loadUrl("file:///android_asset/5.htm");
flag = 4;
} else if(extra.equals("5")) {
webView.loadUrl("file:///android_asset/6.htm");
flag = 5;
} else if(extra.equals("6")) {
webView.loadUrl("file:///android_asset/7.htm");
flag = 6;
} else if(extra.equals("7")) {
webView.loadUrl("file:///android_asset/8.htm");
flag = 7;
} else if(extra.equals("8")) {
webView.loadUrl("file:///android_asset/9.htm");
flag = 8;
} else if(extra.equals("9")) {
webView.loadUrl("file:///android_asset/10.htm");
flag = 9;
} else if(extra.equals("10")) {
webView.loadUrl("file:///android_asset/11.htm");
flag = 10;
}
}
}