質問編集履歴
14
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,7 +12,227 @@
|
|
12
12
|
|
13
13
|
どうぞよろしくお願いします。
|
14
14
|
|
15
|
-
|
15
|
+
9:18分のActivitySecond.java
|
16
|
+
|
17
|
+
もともとのコードにNewUserSet()のように引数を空に変更した状態になりました。
|
18
|
+
|
19
|
+
```java
|
20
|
+
|
21
|
+
package ncmbdataquick.mbaas.com.nifty.datastorequickstart;
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
import android.app.Activity;
|
26
|
+
|
27
|
+
import android.app.AlertDialog;
|
28
|
+
|
29
|
+
import android.content.Intent;
|
30
|
+
|
31
|
+
import android.os.Bundle;
|
32
|
+
|
33
|
+
import android.support.design.widget.FloatingActionButton;
|
34
|
+
|
35
|
+
import android.support.design.widget.Snackbar;
|
36
|
+
|
37
|
+
import android.support.v7.app.AppCompatActivity;
|
38
|
+
|
39
|
+
import android.support.v7.widget.Toolbar;
|
40
|
+
|
41
|
+
import android.view.View;
|
42
|
+
|
43
|
+
import android.widget.Button;
|
44
|
+
|
45
|
+
import android.widget.EditText;
|
46
|
+
|
47
|
+
import com.nifty.cloud.mb.core.DoneCallback;
|
48
|
+
|
49
|
+
import com.nifty.cloud.mb.core.NCMB;
|
50
|
+
|
51
|
+
import com.nifty.cloud.mb.core.NCMBException;
|
52
|
+
|
53
|
+
import com.nifty.cloud.mb.core.NCMBObject;
|
54
|
+
|
55
|
+
import javax.security.auth.callback.PasswordCallback;
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
public class ActivitySecond extends Activity {
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
//変数を宣言する
|
64
|
+
|
65
|
+
private EditText mUserName;
|
66
|
+
|
67
|
+
private EditText mPassword;
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
@Override
|
74
|
+
|
75
|
+
protected void onCreate(Bundle savedInstanceState) {
|
76
|
+
|
77
|
+
super.onCreate(savedInstanceState);
|
78
|
+
|
79
|
+
setContentView(R.layout.activity_activity_second);
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
//**************** APIキーの設定とSDKの初期化 **********************
|
86
|
+
|
87
|
+
NCMB.initialize(this, "");
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
Button sendButton = (Button) findViewById(R.id.ToLogin);
|
94
|
+
|
95
|
+
sendButton.setOnClickListener(new View.OnClickListener() {
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
//ここに新規登録へのボタンを押した時を作る
|
100
|
+
|
101
|
+
@Override
|
102
|
+
|
103
|
+
//登録ボタンを押したら、登録完了のポップを出しログインへボタンを押しログインページに戻るようにする。
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
public void onClick(View v) {
|
108
|
+
|
109
|
+
if (v.getId() == R.id.ToLogin) {
|
110
|
+
|
111
|
+
//この下のclassはログインページ
|
112
|
+
|
113
|
+
Intent intent = new Intent(getApplication(), ActivityThird.class);
|
114
|
+
|
115
|
+
startActivity(intent);
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
});
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
//このメソッドを呼び出せば、PasswordとUserIdがセットされるようにする。
|
130
|
+
|
131
|
+
public void NewUserSet() {
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
//NewUserAddというデータベースのクラス
|
136
|
+
|
137
|
+
final NCMBObject obj2 = new NCMBObject("NewUserAdd");
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
mUserName = (EditText) findViewById(R.id.UserName);//ユーザーが入力するUserName
|
142
|
+
|
143
|
+
mPassword = (EditText) findViewById(R.id.Password);//ユーザーが入力するPassword
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
String userName = mUserName.getText().toString();
|
148
|
+
|
149
|
+
String password = mPassword.getText().toString();
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
obj2.put("Password", password);
|
154
|
+
|
155
|
+
obj2.put("UserName", userName);
|
156
|
+
|
157
|
+
obj2.saveInBackground(new DoneCallback() {
|
158
|
+
|
159
|
+
@Override
|
160
|
+
|
161
|
+
public void done(NCMBException e) {
|
162
|
+
|
163
|
+
if (e != null) {
|
164
|
+
|
165
|
+
//保存失敗
|
166
|
+
|
167
|
+
new AlertDialog.Builder(ActivitySecond.this)
|
168
|
+
|
169
|
+
.setTitle("Notification from Nifty")
|
170
|
+
|
171
|
+
.setMessage("Error:" + e.getMessage())
|
172
|
+
|
173
|
+
.setPositiveButton("OK", null)
|
174
|
+
|
175
|
+
.show();
|
176
|
+
|
177
|
+
} else {
|
178
|
+
|
179
|
+
//保存成功
|
180
|
+
|
181
|
+
new AlertDialog.Builder(ActivitySecond.this)
|
182
|
+
|
183
|
+
.setTitle("Notification from Nifty")
|
184
|
+
|
185
|
+
.setMessage("Save successfull! with ID:" + obj2.getObjectId())
|
186
|
+
|
187
|
+
.setPositiveButton("OK", null)
|
188
|
+
|
189
|
+
.show();
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
//ここにActivityの変更を入れればいきなり成功したらログイン画面のActivityThirdにいける
|
194
|
+
|
195
|
+
Button newUserSetButton = (Button) findViewById(R.id.NewUserSet);
|
196
|
+
|
197
|
+
newUserSetButton.setOnClickListener(new View.OnClickListener() {
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
//この下のonClickがNewUserSetボタンが押された時に起動するようにしたい
|
202
|
+
|
203
|
+
@Override
|
204
|
+
|
205
|
+
public void onClick(View v) {
|
206
|
+
|
207
|
+
//本当はThirdに行くのはToLoginだけどこの場合はNewUserSet
|
208
|
+
|
209
|
+
if (v.getId() == R.id.NewUserSet) {
|
210
|
+
|
211
|
+
Intent intent = new Intent(getApplication(), ActivityThird.class);
|
212
|
+
|
213
|
+
startActivity(intent);
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
}
|
218
|
+
|
219
|
+
});
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
}
|
228
|
+
|
229
|
+
});
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
}
|
234
|
+
|
235
|
+
}
|
16
236
|
|
17
237
|
|
18
238
|
|
@@ -20,9 +240,7 @@
|
|
20
240
|
|
21
241
|
```
|
22
242
|
|
23
|
-
9:18分のActivitySecond.java
|
24
|
-
|
25
|
-
|
243
|
+
できました。
|
26
244
|
|
27
245
|
```java
|
28
246
|
|
@@ -64,7 +282,7 @@
|
|
64
282
|
|
65
283
|
|
66
284
|
|
67
|
-
public class ActivitySecond extends Activity {
|
285
|
+
public class ActivitySecond extends Activity implements View.OnClickListener {
|
68
286
|
|
69
287
|
|
70
288
|
|
@@ -88,8 +306,6 @@
|
|
88
306
|
|
89
307
|
|
90
308
|
|
91
|
-
|
92
|
-
|
93
309
|
//**************** APIキーの設定とSDKの初期化 **********************
|
94
310
|
|
95
311
|
NCMB.initialize(this, "");
|
@@ -98,11 +314,13 @@
|
|
98
314
|
|
99
315
|
|
100
316
|
|
101
|
-
|
317
|
+
findViewById(R.id.ToLogin).setOnClickListener(this);
|
102
|
-
|
318
|
+
|
103
|
-
|
319
|
+
findViewById(R.id.NewUserSet).setOnClickListener(this);
|
320
|
+
|
321
|
+
|
322
|
+
|
104
|
-
|
323
|
+
}
|
105
|
-
|
106
324
|
|
107
325
|
//ここに新規登録へのボタンを押した時を作る
|
108
326
|
|
@@ -110,10 +328,10 @@
|
|
110
328
|
|
111
329
|
//登録ボタンを押したら、登録完了のポップを出しログインへボタンを押しログインページに戻るようにする。
|
112
330
|
|
113
|
-
|
114
|
-
|
115
331
|
public void onClick(View v) {
|
116
332
|
|
333
|
+
|
334
|
+
|
117
335
|
if (v.getId() == R.id.ToLogin) {
|
118
336
|
|
119
337
|
//この下のclassはログインページ
|
@@ -122,340 +340,114 @@
|
|
122
340
|
|
123
341
|
startActivity(intent);
|
124
342
|
|
343
|
+
} else if (v.getId() == R.id.NewUserSet) {
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
//ここにActivityの変更を入れればいきなり成功したらログイン画面のActivityThirdにいける
|
348
|
+
|
349
|
+
NewUserSet();
|
350
|
+
|
125
351
|
}
|
126
352
|
|
127
|
-
|
128
|
-
|
129
353
|
}
|
130
354
|
|
355
|
+
|
356
|
+
|
357
|
+
//このメソッドを呼び出せば、PasswordとUserIdがセットされるようにする。
|
358
|
+
|
359
|
+
public void NewUserSet() {
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
//NewUserAddというデータベースのクラス
|
364
|
+
|
365
|
+
final NCMBObject obj2 = new NCMBObject("NewUserAdd");
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
mUserName = (EditText) findViewById(R.id.UserName);//ユーザーが入力するUserName
|
370
|
+
|
371
|
+
mPassword = (EditText) findViewById(R.id.Password);//ユーザーが入力するPassword
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
String userName = mUserName.getText().toString();
|
376
|
+
|
377
|
+
String password = mPassword.getText().toString();
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
obj2.put("Password", password);
|
382
|
+
|
383
|
+
obj2.put("UserName", userName);
|
384
|
+
|
385
|
+
obj2.saveInBackground(new DoneCallback() {
|
386
|
+
|
387
|
+
@Override
|
388
|
+
|
389
|
+
public void done(NCMBException e) {
|
390
|
+
|
391
|
+
if (e != null) {
|
392
|
+
|
393
|
+
//保存失敗
|
394
|
+
|
395
|
+
new AlertDialog.Builder(ActivitySecond.this)
|
396
|
+
|
397
|
+
.setTitle("Notification from Nifty")
|
398
|
+
|
399
|
+
.setMessage("Error:" + e.getMessage())
|
400
|
+
|
401
|
+
.setPositiveButton("OK", null)
|
402
|
+
|
403
|
+
.show();
|
404
|
+
|
405
|
+
} else {
|
406
|
+
|
407
|
+
//保存成功
|
408
|
+
|
409
|
+
new AlertDialog.Builder(ActivitySecond.this)
|
410
|
+
|
411
|
+
.setTitle("Notification from Nifty")
|
412
|
+
|
413
|
+
.setMessage("Save successfull! with ID:" + obj2.getObjectId())
|
414
|
+
|
415
|
+
.setPositiveButton("OK", null)
|
416
|
+
|
417
|
+
.show();
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
Intent intent = new Intent(getApplication(), ActivityThird.class);
|
424
|
+
|
425
|
+
startActivity(intent);
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
|
434
|
+
|
435
|
+
}
|
436
|
+
|
437
|
+
}
|
438
|
+
|
131
439
|
});
|
132
440
|
|
441
|
+
|
442
|
+
|
133
443
|
}
|
134
444
|
|
135
445
|
|
136
446
|
|
137
|
-
|
447
|
+
|
138
|
-
|
139
|
-
public void NewUserSet() {
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
//NewUserAddというデータベースのクラス
|
144
|
-
|
145
|
-
final NCMBObject obj2 = new NCMBObject("NewUserAdd");
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
mUserName = (EditText) findViewById(R.id.UserName);//ユーザーが入力するUserName
|
150
|
-
|
151
|
-
mPassword = (EditText) findViewById(R.id.Password);//ユーザーが入力するPassword
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
String userName = mUserName.getText().toString();
|
156
|
-
|
157
|
-
String password = mPassword.getText().toString();
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
obj2.put("Password", password);
|
162
|
-
|
163
|
-
obj2.put("UserName", userName);
|
164
|
-
|
165
|
-
obj2.saveInBackground(new DoneCallback() {
|
166
|
-
|
167
|
-
@Override
|
168
|
-
|
169
|
-
public void done(NCMBException e) {
|
170
|
-
|
171
|
-
if (e != null) {
|
172
|
-
|
173
|
-
//保存失敗
|
174
|
-
|
175
|
-
new AlertDialog.Builder(ActivitySecond.this)
|
176
|
-
|
177
|
-
.setTitle("Notification from Nifty")
|
178
|
-
|
179
|
-
.setMessage("Error:" + e.getMessage())
|
180
|
-
|
181
|
-
.setPositiveButton("OK", null)
|
182
|
-
|
183
|
-
.show();
|
184
|
-
|
185
|
-
} else {
|
186
|
-
|
187
|
-
//保存成功
|
188
|
-
|
189
|
-
new AlertDialog.Builder(ActivitySecond.this)
|
190
|
-
|
191
|
-
.setTitle("Notification from Nifty")
|
192
|
-
|
193
|
-
.setMessage("Save successfull! with ID:" + obj2.getObjectId())
|
194
|
-
|
195
|
-
.setPositiveButton("OK", null)
|
196
|
-
|
197
|
-
.show();
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
//ここにActivityの変更を入れればいきなり成功したらログイン画面のActivityThirdにいける
|
202
|
-
|
203
|
-
Button newUserSetButton = (Button) findViewById(R.id.NewUserSet);
|
204
|
-
|
205
|
-
newUserSetButton.setOnClickListener(new View.OnClickListener() {
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
//この下のonClickがNewUserSetボタンが押された時に起動するようにしたい
|
210
|
-
|
211
|
-
@Override
|
212
|
-
|
213
|
-
public void onClick(View v) {
|
214
|
-
|
215
|
-
//本当はThirdに行くのはToLoginだけどこの場合はNewUserSet
|
216
|
-
|
217
|
-
if (v.getId() == R.id.NewUserSet) {
|
218
|
-
|
219
|
-
Intent intent = new Intent(getApplication(), ActivityThird.class);
|
220
|
-
|
221
|
-
startActivity(intent);
|
222
|
-
|
223
|
-
}
|
224
|
-
|
225
|
-
}
|
226
|
-
|
227
|
-
});
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
}
|
234
|
-
|
235
|
-
}
|
236
|
-
|
237
|
-
});
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
}
|
242
448
|
|
243
449
|
}
|
244
450
|
|
245
451
|
|
246
452
|
|
247
|
-
|
248
|
-
|
249
453
|
```
|
250
|
-
|
251
|
-
できました。
|
252
|
-
|
253
|
-
```java
|
254
|
-
|
255
|
-
package ncmbdataquick.mbaas.com.nifty.datastorequickstart;
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
import android.app.Activity;
|
260
|
-
|
261
|
-
import android.app.AlertDialog;
|
262
|
-
|
263
|
-
import android.content.Intent;
|
264
|
-
|
265
|
-
import android.os.Bundle;
|
266
|
-
|
267
|
-
import android.support.design.widget.FloatingActionButton;
|
268
|
-
|
269
|
-
import android.support.design.widget.Snackbar;
|
270
|
-
|
271
|
-
import android.support.v7.app.AppCompatActivity;
|
272
|
-
|
273
|
-
import android.support.v7.widget.Toolbar;
|
274
|
-
|
275
|
-
import android.view.View;
|
276
|
-
|
277
|
-
import android.widget.Button;
|
278
|
-
|
279
|
-
import android.widget.EditText;
|
280
|
-
|
281
|
-
import com.nifty.cloud.mb.core.DoneCallback;
|
282
|
-
|
283
|
-
import com.nifty.cloud.mb.core.NCMB;
|
284
|
-
|
285
|
-
import com.nifty.cloud.mb.core.NCMBException;
|
286
|
-
|
287
|
-
import com.nifty.cloud.mb.core.NCMBObject;
|
288
|
-
|
289
|
-
import javax.security.auth.callback.PasswordCallback;
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
public class ActivitySecond extends Activity implements View.OnClickListener {
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
//変数を宣言する
|
298
|
-
|
299
|
-
private EditText mUserName;
|
300
|
-
|
301
|
-
private EditText mPassword;
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
@Override
|
308
|
-
|
309
|
-
protected void onCreate(Bundle savedInstanceState) {
|
310
|
-
|
311
|
-
super.onCreate(savedInstanceState);
|
312
|
-
|
313
|
-
setContentView(R.layout.activity_activity_second);
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
//**************** APIキーの設定とSDKの初期化 **********************
|
318
|
-
|
319
|
-
NCMB.initialize(this, "");
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
findViewById(R.id.ToLogin).setOnClickListener(this);
|
326
|
-
|
327
|
-
findViewById(R.id.NewUserSet).setOnClickListener(this);
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
}
|
332
|
-
|
333
|
-
//ここに新規登録へのボタンを押した時を作る
|
334
|
-
|
335
|
-
@Override
|
336
|
-
|
337
|
-
//登録ボタンを押したら、登録完了のポップを出しログインへボタンを押しログインページに戻るようにする。
|
338
|
-
|
339
|
-
public void onClick(View v) {
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
if (v.getId() == R.id.ToLogin) {
|
344
|
-
|
345
|
-
//この下のclassはログインページ
|
346
|
-
|
347
|
-
Intent intent = new Intent(getApplication(), ActivityThird.class);
|
348
|
-
|
349
|
-
startActivity(intent);
|
350
|
-
|
351
|
-
} else if (v.getId() == R.id.NewUserSet) {
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
//ここにActivityの変更を入れればいきなり成功したらログイン画面のActivityThirdにいける
|
356
|
-
|
357
|
-
NewUserSet();
|
358
|
-
|
359
|
-
}
|
360
|
-
|
361
|
-
}
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
//このメソッドを呼び出せば、PasswordとUserIdがセットされるようにする。
|
366
|
-
|
367
|
-
public void NewUserSet() {
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
//NewUserAddというデータベースのクラス
|
372
|
-
|
373
|
-
final NCMBObject obj2 = new NCMBObject("NewUserAdd");
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
mUserName = (EditText) findViewById(R.id.UserName);//ユーザーが入力するUserName
|
378
|
-
|
379
|
-
mPassword = (EditText) findViewById(R.id.Password);//ユーザーが入力するPassword
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
String userName = mUserName.getText().toString();
|
384
|
-
|
385
|
-
String password = mPassword.getText().toString();
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
obj2.put("Password", password);
|
390
|
-
|
391
|
-
obj2.put("UserName", userName);
|
392
|
-
|
393
|
-
obj2.saveInBackground(new DoneCallback() {
|
394
|
-
|
395
|
-
@Override
|
396
|
-
|
397
|
-
public void done(NCMBException e) {
|
398
|
-
|
399
|
-
if (e != null) {
|
400
|
-
|
401
|
-
//保存失敗
|
402
|
-
|
403
|
-
new AlertDialog.Builder(ActivitySecond.this)
|
404
|
-
|
405
|
-
.setTitle("Notification from Nifty")
|
406
|
-
|
407
|
-
.setMessage("Error:" + e.getMessage())
|
408
|
-
|
409
|
-
.setPositiveButton("OK", null)
|
410
|
-
|
411
|
-
.show();
|
412
|
-
|
413
|
-
} else {
|
414
|
-
|
415
|
-
//保存成功
|
416
|
-
|
417
|
-
new AlertDialog.Builder(ActivitySecond.this)
|
418
|
-
|
419
|
-
.setTitle("Notification from Nifty")
|
420
|
-
|
421
|
-
.setMessage("Save successfull! with ID:" + obj2.getObjectId())
|
422
|
-
|
423
|
-
.setPositiveButton("OK", null)
|
424
|
-
|
425
|
-
.show();
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
Intent intent = new Intent(getApplication(), ActivityThird.class);
|
432
|
-
|
433
|
-
startActivity(intent);
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
}
|
444
|
-
|
445
|
-
}
|
446
|
-
|
447
|
-
});
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
}
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
}
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
```
|
13
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,10 +16,54 @@
|
|
16
16
|
|
17
17
|
|
18
18
|
|
19
|
+
|
20
|
+
|
21
|
+
```
|
22
|
+
|
19
|
-
ActivitySecond.java
|
23
|
+
9:18分のActivitySecond.java
|
24
|
+
|
25
|
+
もともとのコードにNewUserSet()のように引数を空に変更した状態になりました。
|
20
26
|
|
21
27
|
```java
|
22
28
|
|
29
|
+
package ncmbdataquick.mbaas.com.nifty.datastorequickstart;
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
import android.app.Activity;
|
34
|
+
|
35
|
+
import android.app.AlertDialog;
|
36
|
+
|
37
|
+
import android.content.Intent;
|
38
|
+
|
39
|
+
import android.os.Bundle;
|
40
|
+
|
41
|
+
import android.support.design.widget.FloatingActionButton;
|
42
|
+
|
43
|
+
import android.support.design.widget.Snackbar;
|
44
|
+
|
45
|
+
import android.support.v7.app.AppCompatActivity;
|
46
|
+
|
47
|
+
import android.support.v7.widget.Toolbar;
|
48
|
+
|
49
|
+
import android.view.View;
|
50
|
+
|
51
|
+
import android.widget.Button;
|
52
|
+
|
53
|
+
import android.widget.EditText;
|
54
|
+
|
55
|
+
import com.nifty.cloud.mb.core.DoneCallback;
|
56
|
+
|
57
|
+
import com.nifty.cloud.mb.core.NCMB;
|
58
|
+
|
59
|
+
import com.nifty.cloud.mb.core.NCMBException;
|
60
|
+
|
61
|
+
import com.nifty.cloud.mb.core.NCMBObject;
|
62
|
+
|
63
|
+
import javax.security.auth.callback.PasswordCallback;
|
64
|
+
|
65
|
+
|
66
|
+
|
23
67
|
public class ActivitySecond extends Activity {
|
24
68
|
|
25
69
|
|
@@ -66,7 +110,7 @@
|
|
66
110
|
|
67
111
|
//登録ボタンを押したら、登録完了のポップを出しログインへボタンを押しログインページに戻るようにする。
|
68
112
|
|
69
|
-
|
113
|
+
|
70
114
|
|
71
115
|
public void onClick(View v) {
|
72
116
|
|
@@ -80,10 +124,6 @@
|
|
80
124
|
|
81
125
|
}
|
82
126
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
127
|
|
88
128
|
|
89
129
|
}
|
@@ -94,13 +134,9 @@
|
|
94
134
|
|
95
135
|
|
96
136
|
|
97
|
-
|
98
|
-
|
99
137
|
//このメソッドを呼び出せば、PasswordとUserIdがセットされるようにする。
|
100
138
|
|
101
|
-
|
102
|
-
|
103
|
-
public void NewUserSet(
|
139
|
+
public void NewUserSet() {
|
104
140
|
|
105
141
|
|
106
142
|
|
@@ -108,25 +144,17 @@
|
|
108
144
|
|
109
145
|
final NCMBObject obj2 = new NCMBObject("NewUserAdd");
|
110
146
|
|
111
|
-
|
147
|
+
|
112
|
-
|
113
|
-
|
148
|
+
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
//ここに新しく上で宣言した、UserNameとPasswordを(XMLのViewを)取得する。
|
118
|
-
|
119
|
-
//この下のR.id.UserNameのところには、何書くべきなのか?
|
120
|
-
|
121
|
-
mUserName=(EditText)findViewById(R.id.UserName);//ユーザーが入力するUserName
|
149
|
+
mUserName = (EditText) findViewById(R.id.UserName);//ユーザーが入力するUserName
|
122
|
-
|
150
|
+
|
123
|
-
mPassword=(EditText)findViewById(R.id.Password);//ユーザーが入力するPassword
|
151
|
+
mPassword = (EditText) findViewById(R.id.Password);//ユーザーが入力するPassword
|
124
|
-
|
125
|
-
|
126
|
-
|
152
|
+
|
153
|
+
|
154
|
+
|
127
|
-
String userName=mUserName.getText().toString();
|
155
|
+
String userName = mUserName.getText().toString();
|
128
|
-
|
156
|
+
|
129
|
-
String password=mPassword.getText().toString();
|
157
|
+
String password = mPassword.getText().toString();
|
130
158
|
|
131
159
|
|
132
160
|
|
@@ -170,18 +198,14 @@
|
|
170
198
|
|
171
199
|
|
172
200
|
|
173
|
-
|
174
|
-
|
175
201
|
//ここにActivityの変更を入れればいきなり成功したらログイン画面のActivityThirdにいける
|
176
202
|
|
177
|
-
Button newUserSetButton=(Button)findViewById(R.id.NewUserSet);
|
203
|
+
Button newUserSetButton = (Button) findViewById(R.id.NewUserSet);
|
178
204
|
|
179
205
|
newUserSetButton.setOnClickListener(new View.OnClickListener() {
|
180
206
|
|
181
207
|
|
182
208
|
|
183
|
-
|
184
|
-
|
185
209
|
//この下のonClickがNewUserSetボタンが押された時に起動するようにしたい
|
186
210
|
|
187
211
|
@Override
|
@@ -206,10 +230,6 @@
|
|
206
230
|
|
207
231
|
|
208
232
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
233
|
}
|
214
234
|
|
215
235
|
}
|
@@ -218,29 +238,17 @@
|
|
218
238
|
|
219
239
|
|
220
240
|
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
241
|
}
|
230
242
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
243
|
}
|
236
244
|
|
237
245
|
|
238
246
|
|
247
|
+
|
248
|
+
|
239
249
|
```
|
240
250
|
|
241
|
-
|
251
|
+
できました。
|
242
|
-
|
243
|
-
上に記述してあるコードにNewUserSet()のように引数を空に変更した状態になりました。
|
244
252
|
|
245
253
|
```java
|
246
254
|
|
@@ -282,7 +290,7 @@
|
|
282
290
|
|
283
291
|
|
284
292
|
|
285
|
-
public class ActivitySecond extends Activity {
|
293
|
+
public class ActivitySecond extends Activity implements View.OnClickListener {
|
286
294
|
|
287
295
|
|
288
296
|
|
@@ -306,8 +314,6 @@
|
|
306
314
|
|
307
315
|
|
308
316
|
|
309
|
-
|
310
|
-
|
311
317
|
//**************** APIキーの設定とSDKの初期化 **********************
|
312
318
|
|
313
319
|
NCMB.initialize(this, "");
|
@@ -316,11 +322,13 @@
|
|
316
322
|
|
317
323
|
|
318
324
|
|
319
|
-
|
325
|
+
findViewById(R.id.ToLogin).setOnClickListener(this);
|
320
|
-
|
326
|
+
|
321
|
-
|
327
|
+
findViewById(R.id.NewUserSet).setOnClickListener(this);
|
328
|
+
|
329
|
+
|
330
|
+
|
322
|
-
|
331
|
+
}
|
323
|
-
|
324
332
|
|
325
333
|
//ここに新規登録へのボタンを押した時を作る
|
326
334
|
|
@@ -328,10 +336,10 @@
|
|
328
336
|
|
329
337
|
//登録ボタンを押したら、登録完了のポップを出しログインへボタンを押しログインページに戻るようにする。
|
330
338
|
|
331
|
-
|
332
|
-
|
333
339
|
public void onClick(View v) {
|
334
340
|
|
341
|
+
|
342
|
+
|
335
343
|
if (v.getId() == R.id.ToLogin) {
|
336
344
|
|
337
345
|
//この下のclassはログインページ
|
@@ -340,128 +348,114 @@
|
|
340
348
|
|
341
349
|
startActivity(intent);
|
342
350
|
|
351
|
+
} else if (v.getId() == R.id.NewUserSet) {
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
//ここにActivityの変更を入れればいきなり成功したらログイン画面のActivityThirdにいける
|
356
|
+
|
357
|
+
NewUserSet();
|
358
|
+
|
343
359
|
}
|
344
360
|
|
345
|
-
|
346
|
-
|
347
361
|
}
|
348
362
|
|
363
|
+
|
364
|
+
|
365
|
+
//このメソッドを呼び出せば、PasswordとUserIdがセットされるようにする。
|
366
|
+
|
367
|
+
public void NewUserSet() {
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
//NewUserAddというデータベースのクラス
|
372
|
+
|
373
|
+
final NCMBObject obj2 = new NCMBObject("NewUserAdd");
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
mUserName = (EditText) findViewById(R.id.UserName);//ユーザーが入力するUserName
|
378
|
+
|
379
|
+
mPassword = (EditText) findViewById(R.id.Password);//ユーザーが入力するPassword
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
String userName = mUserName.getText().toString();
|
384
|
+
|
385
|
+
String password = mPassword.getText().toString();
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
obj2.put("Password", password);
|
390
|
+
|
391
|
+
obj2.put("UserName", userName);
|
392
|
+
|
393
|
+
obj2.saveInBackground(new DoneCallback() {
|
394
|
+
|
395
|
+
@Override
|
396
|
+
|
397
|
+
public void done(NCMBException e) {
|
398
|
+
|
399
|
+
if (e != null) {
|
400
|
+
|
401
|
+
//保存失敗
|
402
|
+
|
403
|
+
new AlertDialog.Builder(ActivitySecond.this)
|
404
|
+
|
405
|
+
.setTitle("Notification from Nifty")
|
406
|
+
|
407
|
+
.setMessage("Error:" + e.getMessage())
|
408
|
+
|
409
|
+
.setPositiveButton("OK", null)
|
410
|
+
|
411
|
+
.show();
|
412
|
+
|
413
|
+
} else {
|
414
|
+
|
415
|
+
//保存成功
|
416
|
+
|
417
|
+
new AlertDialog.Builder(ActivitySecond.this)
|
418
|
+
|
419
|
+
.setTitle("Notification from Nifty")
|
420
|
+
|
421
|
+
.setMessage("Save successfull! with ID:" + obj2.getObjectId())
|
422
|
+
|
423
|
+
.setPositiveButton("OK", null)
|
424
|
+
|
425
|
+
.show();
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
Intent intent = new Intent(getApplication(), ActivityThird.class);
|
432
|
+
|
433
|
+
startActivity(intent);
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
}
|
444
|
+
|
445
|
+
}
|
446
|
+
|
349
447
|
});
|
350
448
|
|
449
|
+
|
450
|
+
|
351
451
|
}
|
352
452
|
|
353
453
|
|
354
454
|
|
355
|
-
|
455
|
+
|
356
|
-
|
357
|
-
public void NewUserSet() {
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
//NewUserAddというデータベースのクラス
|
362
|
-
|
363
|
-
final NCMBObject obj2 = new NCMBObject("NewUserAdd");
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
mUserName = (EditText) findViewById(R.id.UserName);//ユーザーが入力するUserName
|
368
|
-
|
369
|
-
mPassword = (EditText) findViewById(R.id.Password);//ユーザーが入力するPassword
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
String userName = mUserName.getText().toString();
|
374
|
-
|
375
|
-
String password = mPassword.getText().toString();
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
obj2.put("Password", password);
|
380
|
-
|
381
|
-
obj2.put("UserName", userName);
|
382
|
-
|
383
|
-
obj2.saveInBackground(new DoneCallback() {
|
384
|
-
|
385
|
-
@Override
|
386
|
-
|
387
|
-
public void done(NCMBException e) {
|
388
|
-
|
389
|
-
if (e != null) {
|
390
|
-
|
391
|
-
//保存失敗
|
392
|
-
|
393
|
-
new AlertDialog.Builder(ActivitySecond.this)
|
394
|
-
|
395
|
-
.setTitle("Notification from Nifty")
|
396
|
-
|
397
|
-
.setMessage("Error:" + e.getMessage())
|
398
|
-
|
399
|
-
.setPositiveButton("OK", null)
|
400
|
-
|
401
|
-
.show();
|
402
|
-
|
403
|
-
} else {
|
404
|
-
|
405
|
-
//保存成功
|
406
|
-
|
407
|
-
new AlertDialog.Builder(ActivitySecond.this)
|
408
|
-
|
409
|
-
.setTitle("Notification from Nifty")
|
410
|
-
|
411
|
-
.setMessage("Save successfull! with ID:" + obj2.getObjectId())
|
412
|
-
|
413
|
-
.setPositiveButton("OK", null)
|
414
|
-
|
415
|
-
.show();
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
//ここにActivityの変更を入れればいきなり成功したらログイン画面のActivityThirdにいける
|
420
|
-
|
421
|
-
Button newUserSetButton = (Button) findViewById(R.id.NewUserSet);
|
422
|
-
|
423
|
-
newUserSetButton.setOnClickListener(new View.OnClickListener() {
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
//この下のonClickがNewUserSetボタンが押された時に起動するようにしたい
|
428
|
-
|
429
|
-
@Override
|
430
|
-
|
431
|
-
public void onClick(View v) {
|
432
|
-
|
433
|
-
//本当はThirdに行くのはToLoginだけどこの場合はNewUserSet
|
434
|
-
|
435
|
-
if (v.getId() == R.id.NewUserSet) {
|
436
|
-
|
437
|
-
Intent intent = new Intent(getApplication(), ActivityThird.class);
|
438
|
-
|
439
|
-
startActivity(intent);
|
440
|
-
|
441
|
-
}
|
442
|
-
|
443
|
-
}
|
444
|
-
|
445
|
-
});
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
}
|
452
|
-
|
453
|
-
}
|
454
|
-
|
455
|
-
});
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
}
|
460
456
|
|
461
457
|
}
|
462
458
|
|
463
459
|
|
464
460
|
|
465
|
-
|
466
|
-
|
467
461
|
```
|
12
詳細の変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -310,7 +310,7 @@
|
|
310
310
|
|
311
311
|
//**************** APIキーの設定とSDKの初期化 **********************
|
312
312
|
|
313
|
-
NCMB.initialize(this, "
|
313
|
+
NCMB.initialize(this, "");
|
314
314
|
|
315
315
|
|
316
316
|
|
11
詳細のついあk
test
CHANGED
File without changes
|
test
CHANGED
@@ -310,7 +310,7 @@
|
|
310
310
|
|
311
311
|
//**************** APIキーの設定とSDKの初期化 **********************
|
312
312
|
|
313
|
-
NCMB.initialize(this, "");
|
313
|
+
NCMB.initialize(this, "78da4765984f7add2ddd2b22ed978d4bf744818563c44fbdd0f3be19b7430a43", "bce814b5040d532d488c176b114fa3463552c10d9e226b9090dbe959b2f0dc46");
|
314
314
|
|
315
315
|
|
316
316
|
|
@@ -352,12 +352,8 @@
|
|
352
352
|
|
353
353
|
|
354
354
|
|
355
|
-
|
356
|
-
|
357
355
|
//このメソッドを呼び出せば、PasswordとUserIdがセットされるようにする。
|
358
356
|
|
359
|
-
|
360
|
-
|
361
357
|
public void NewUserSet() {
|
362
358
|
|
363
359
|
|
@@ -366,15 +362,7 @@
|
|
366
362
|
|
367
363
|
final NCMBObject obj2 = new NCMBObject("NewUserAdd");
|
368
364
|
|
369
|
-
|
365
|
+
|
370
|
-
|
371
|
-
//Buttonと同様にEditTextをインスタンス化し、EditTextから文字列を取得してください。
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
//ここに新しく上で宣言した、UserNameとPasswordを(XMLのViewを)取得する。
|
376
|
-
|
377
|
-
//この下のR.id.UserNameのところには、何書くべきなのか?
|
378
366
|
|
379
367
|
mUserName = (EditText) findViewById(R.id.UserName);//ユーザーが入力するUserName
|
380
368
|
|
@@ -428,8 +416,6 @@
|
|
428
416
|
|
429
417
|
|
430
418
|
|
431
|
-
|
432
|
-
|
433
419
|
//ここにActivityの変更を入れればいきなり成功したらログイン画面のActivityThirdにいける
|
434
420
|
|
435
421
|
Button newUserSetButton = (Button) findViewById(R.id.NewUserSet);
|
@@ -438,8 +424,6 @@
|
|
438
424
|
|
439
425
|
|
440
426
|
|
441
|
-
|
442
|
-
|
443
427
|
//この下のonClickがNewUserSetボタンが押された時に起動するようにしたい
|
444
428
|
|
445
429
|
@Override
|
@@ -478,4 +462,6 @@
|
|
478
462
|
|
479
463
|
|
480
464
|
|
465
|
+
|
466
|
+
|
481
467
|
```
|
10
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -310,7 +310,7 @@
|
|
310
310
|
|
311
311
|
//**************** APIキーの設定とSDKの初期化 **********************
|
312
312
|
|
313
|
-
NCMB.initialize(this, "
|
313
|
+
NCMB.initialize(this, "");
|
314
314
|
|
315
315
|
|
316
316
|
|
9
コードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -238,7 +238,9 @@
|
|
238
238
|
|
239
239
|
```
|
240
240
|
|
241
|
-
9:1
|
241
|
+
9:18分のActivitySecond.java
|
242
|
+
|
243
|
+
上に記述してあるコードにNewUserSet()のように引数を空に変更した状態になりました。
|
242
244
|
|
243
245
|
```java
|
244
246
|
|
@@ -292,6 +294,8 @@
|
|
292
294
|
|
293
295
|
|
294
296
|
|
297
|
+
|
298
|
+
|
295
299
|
@Override
|
296
300
|
|
297
301
|
protected void onCreate(Bundle savedInstanceState) {
|
@@ -302,55 +306,163 @@
|
|
302
306
|
|
303
307
|
|
304
308
|
|
309
|
+
|
310
|
+
|
305
311
|
//**************** APIキーの設定とSDKの初期化 **********************
|
306
312
|
|
307
313
|
NCMB.initialize(this, "78da4765984f7add2ddd2b22ed978d4bf744818563c44fbdd0f3be19b7430a43", "bce814b5040d532d488c176b114fa3463552c10d9e226b9090dbe959b2f0dc46");
|
308
314
|
|
309
315
|
|
310
316
|
|
317
|
+
|
318
|
+
|
311
|
-
Button sendButton = (Button) findViewById(R.id.
|
319
|
+
Button sendButton = (Button) findViewById(R.id.ToLogin);
|
312
320
|
|
313
321
|
sendButton.setOnClickListener(new View.OnClickListener() {
|
314
322
|
|
315
323
|
|
316
324
|
|
325
|
+
//ここに新規登録へのボタンを押した時を作る
|
326
|
+
|
317
327
|
@Override
|
318
328
|
|
329
|
+
//登録ボタンを押したら、登録完了のポップを出しログインへボタンを押しログインページに戻るようにする。
|
330
|
+
|
331
|
+
|
332
|
+
|
319
333
|
public void onClick(View v) {
|
320
334
|
|
321
|
-
|
322
|
-
|
323
|
-
if (v.getId() == R.id.
|
335
|
+
if (v.getId() == R.id.ToLogin) {
|
324
|
-
|
325
|
-
|
326
|
-
|
336
|
+
|
327
|
-
|
337
|
+
//この下のclassはログインページ
|
328
|
-
|
338
|
+
|
329
|
-
Intent intent = new Intent(getApplication(), Activity
|
339
|
+
Intent intent = new Intent(getApplication(), ActivityThird.class);
|
330
340
|
|
331
341
|
startActivity(intent);
|
332
342
|
|
333
343
|
}
|
334
344
|
|
345
|
+
|
346
|
+
|
335
347
|
}
|
336
348
|
|
337
349
|
});
|
338
350
|
|
351
|
+
}
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
//このメソッドを呼び出せば、PasswordとUserIdがセットされるようにする。
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
public void NewUserSet() {
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
//NewUserAddというデータベースのクラス
|
366
|
+
|
367
|
+
final NCMBObject obj2 = new NCMBObject("NewUserAdd");
|
368
|
+
|
369
|
+
//ここをPlanText(TextView)にユーザーが打ち込んだ値にする。
|
370
|
+
|
371
|
+
//Buttonと同様にEditTextをインスタンス化し、EditTextから文字列を取得してください。
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
//ここに新しく上で宣言した、UserNameとPasswordを(XMLのViewを)取得する。
|
376
|
+
|
377
|
+
//この下のR.id.UserNameのところには、何書くべきなのか?
|
378
|
+
|
379
|
+
mUserName = (EditText) findViewById(R.id.UserName);//ユーザーが入力するUserName
|
380
|
+
|
381
|
+
mPassword = (EditText) findViewById(R.id.Password);//ユーザーが入力するPassword
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
String userName = mUserName.getText().toString();
|
386
|
+
|
339
|
-
|
387
|
+
String password = mPassword.getText().toString();
|
388
|
+
|
389
|
+
|
390
|
+
|
340
|
-
|
391
|
+
obj2.put("Password", password);
|
392
|
+
|
393
|
+
obj2.put("UserName", userName);
|
394
|
+
|
341
|
-
|
395
|
+
obj2.saveInBackground(new DoneCallback() {
|
342
|
-
|
343
|
-
|
344
396
|
|
345
397
|
@Override
|
346
398
|
|
399
|
+
public void done(NCMBException e) {
|
400
|
+
|
401
|
+
if (e != null) {
|
402
|
+
|
403
|
+
//保存失敗
|
404
|
+
|
405
|
+
new AlertDialog.Builder(ActivitySecond.this)
|
406
|
+
|
407
|
+
.setTitle("Notification from Nifty")
|
408
|
+
|
409
|
+
.setMessage("Error:" + e.getMessage())
|
410
|
+
|
411
|
+
.setPositiveButton("OK", null)
|
412
|
+
|
413
|
+
.show();
|
414
|
+
|
415
|
+
} else {
|
416
|
+
|
417
|
+
//保存成功
|
418
|
+
|
419
|
+
new AlertDialog.Builder(ActivitySecond.this)
|
420
|
+
|
421
|
+
.setTitle("Notification from Nifty")
|
422
|
+
|
423
|
+
.setMessage("Save successfull! with ID:" + obj2.getObjectId())
|
424
|
+
|
425
|
+
.setPositiveButton("OK", null)
|
426
|
+
|
427
|
+
.show();
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
//ここにActivityの変更を入れればいきなり成功したらログイン画面のActivityThirdにいける
|
434
|
+
|
435
|
+
Button newUserSetButton = (Button) findViewById(R.id.NewUserSet);
|
436
|
+
|
437
|
+
newUserSetButton.setOnClickListener(new View.OnClickListener() {
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
//この下のonClickがNewUserSetボタンが押された時に起動するようにしたい
|
444
|
+
|
445
|
+
@Override
|
446
|
+
|
347
|
-
public void onClick(View v) {
|
447
|
+
public void onClick(View v) {
|
448
|
+
|
348
|
-
|
449
|
+
//本当はThirdに行くのはToLoginだけどこの場合はNewUserSet
|
450
|
+
|
349
|
-
if (v.getId() == R.id.
|
451
|
+
if (v.getId() == R.id.NewUserSet) {
|
350
|
-
|
452
|
+
|
351
|
-
Intent intent = new Intent(getApplication(), ActivityThird.class);
|
453
|
+
Intent intent = new Intent(getApplication(), ActivityThird.class);
|
352
|
-
|
454
|
+
|
353
|
-
startActivity(intent);
|
455
|
+
startActivity(intent);
|
456
|
+
|
457
|
+
}
|
458
|
+
|
459
|
+
}
|
460
|
+
|
461
|
+
});
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
|
354
466
|
|
355
467
|
}
|
356
468
|
|
@@ -358,100 +470,12 @@
|
|
358
470
|
|
359
471
|
});
|
360
472
|
|
473
|
+
|
474
|
+
|
361
475
|
}
|
362
476
|
|
363
|
-
|
364
|
-
|
365
|
-
//このメソッドを呼び出せば、PasswordとUserIdがセットされるようにする
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
public void NewUserSet() {
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
//NewUserAddというデータベースのクラス
|
374
|
-
|
375
|
-
final NCMBObject obj2 = new NCMBObject("NewUserAdd");
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
mUserName = (EditText) findViewById(R.id.UserName);//ユーザーが入力するUserName
|
380
|
-
|
381
|
-
mPassword = (EditText) findViewById(R.id.Password);//ユーザーが入力するPassword
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
String userName = mUserName.getText().toString();
|
386
|
-
|
387
|
-
String password = mPassword.getText().toString();
|
388
|
-
|
389
|
-
obj2.put("Password", password);
|
390
|
-
|
391
|
-
obj2.put("UserName", userName);
|
392
|
-
|
393
|
-
obj2.saveInBackground(new DoneCallback() {
|
394
|
-
|
395
|
-
@Override
|
396
|
-
|
397
|
-
public void done(NCMBException e) {
|
398
|
-
|
399
|
-
if (e != null) {
|
400
|
-
|
401
|
-
//保存失敗
|
402
|
-
|
403
|
-
new AlertDialog.Builder(ActivitySecond.this)
|
404
|
-
|
405
|
-
.setTitle("Notification from Nifty")
|
406
|
-
|
407
|
-
.setMessage("Error:" + e.getMessage())
|
408
|
-
|
409
|
-
.setPositiveButton("OK", null)
|
410
|
-
|
411
|
-
.show();
|
412
|
-
|
413
|
-
} else {
|
414
|
-
|
415
|
-
//保存成功
|
416
|
-
|
417
|
-
new AlertDialog.Builder(ActivitySecond.this)
|
418
|
-
|
419
|
-
.setTitle("Notification from Nifty")
|
420
|
-
|
421
|
-
.setMessage("Save successfull! with ID:" + obj2.getObjectId())
|
422
|
-
|
423
|
-
.setPositiveButton("OK", null)
|
424
|
-
|
425
|
-
.show();
|
426
|
-
|
427
|
-
}
|
428
|
-
|
429
|
-
}
|
430
|
-
|
431
|
-
});
|
432
|
-
|
433
|
-
}
|
434
|
-
|
435
477
|
}
|
436
478
|
|
437
479
|
|
438
480
|
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
481
|
```
|
8
できるだけ直しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -238,7 +238,7 @@
|
|
238
238
|
|
239
239
|
```
|
240
240
|
|
241
|
-
|
241
|
+
9:10分のActivitySecond.java
|
242
242
|
|
243
243
|
```java
|
244
244
|
|
@@ -246,41 +246,37 @@
|
|
246
246
|
|
247
247
|
|
248
248
|
|
249
|
-
|
249
|
+
import android.app.Activity;
|
250
|
-
|
250
|
+
|
251
|
-
|
251
|
+
import android.app.AlertDialog;
|
252
|
-
|
252
|
+
|
253
|
-
|
253
|
+
import android.content.Intent;
|
254
|
-
|
254
|
+
|
255
|
-
|
255
|
+
import android.os.Bundle;
|
256
|
-
|
256
|
+
|
257
|
-
|
257
|
+
import android.support.design.widget.FloatingActionButton;
|
258
|
-
|
258
|
+
|
259
|
-
|
259
|
+
import android.support.design.widget.Snackbar;
|
260
|
-
|
260
|
+
|
261
|
-
|
261
|
+
import android.support.v7.app.AppCompatActivity;
|
262
|
-
|
262
|
+
|
263
|
-
|
263
|
+
import android.support.v7.widget.Toolbar;
|
264
|
-
|
264
|
+
|
265
|
-
|
265
|
+
import android.view.View;
|
266
|
-
|
266
|
+
|
267
|
-
|
267
|
+
import android.widget.Button;
|
268
|
-
|
268
|
+
|
269
|
-
|
269
|
+
import android.widget.EditText;
|
270
|
-
|
271
|
-
|
272
|
-
|
270
|
+
|
273
|
-
|
271
|
+
import com.nifty.cloud.mb.core.DoneCallback;
|
274
|
-
|
272
|
+
|
275
|
-
|
273
|
+
import com.nifty.cloud.mb.core.NCMB;
|
276
|
-
|
274
|
+
|
277
|
-
|
275
|
+
import com.nifty.cloud.mb.core.NCMBException;
|
278
|
-
|
276
|
+
|
279
|
-
|
277
|
+
import com.nifty.cloud.mb.core.NCMBObject;
|
280
|
-
|
281
|
-
|
282
|
-
|
278
|
+
|
283
|
-
|
279
|
+
import javax.security.auth.callback.PasswordCallback;
|
284
280
|
|
285
281
|
|
286
282
|
|
@@ -296,8 +292,6 @@
|
|
296
292
|
|
297
293
|
|
298
294
|
|
299
|
-
|
300
|
-
|
301
295
|
@Override
|
302
296
|
|
303
297
|
protected void onCreate(Bundle savedInstanceState) {
|
@@ -308,206 +302,136 @@
|
|
308
302
|
|
309
303
|
|
310
304
|
|
311
|
-
|
312
|
-
|
313
305
|
//**************** APIキーの設定とSDKの初期化 **********************
|
314
306
|
|
315
307
|
NCMB.initialize(this, "78da4765984f7add2ddd2b22ed978d4bf744818563c44fbdd0f3be19b7430a43", "bce814b5040d532d488c176b114fa3463552c10d9e226b9090dbe959b2f0dc46");
|
316
308
|
|
317
309
|
|
318
310
|
|
319
|
-
|
311
|
+
Button sendButton = (Button) findViewById(R.id.NewUserAdd);
|
312
|
+
|
320
|
-
|
313
|
+
sendButton.setOnClickListener(new View.OnClickListener() {
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
@Override
|
318
|
+
|
319
|
+
public void onClick(View v) {
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
if (v.getId() == R.id.NewUserAdd) {
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
Button sendButton = (Button) findViewById(R.id.NewUserAdd);
|
328
|
+
|
329
|
+
Intent intent = new Intent(getApplication(), ActivitySecond.class);
|
330
|
+
|
331
|
+
startActivity(intent);
|
332
|
+
|
333
|
+
}
|
334
|
+
|
335
|
+
}
|
336
|
+
|
337
|
+
});
|
338
|
+
|
321
|
-
Button
|
339
|
+
Button toLoginButton = (Button) findViewById(R.id.ToLogin);
|
322
|
-
|
340
|
+
|
323
|
-
|
341
|
+
toLoginButton.setOnClickListener(new View.OnClickListener() {
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
@Override
|
346
|
+
|
347
|
+
public void onClick(View v) {
|
348
|
+
|
349
|
+
if (v.getId() == R.id.ToLogin) {
|
350
|
+
|
351
|
+
Intent intent = new Intent(getApplication(), ActivityThird.class);
|
352
|
+
|
353
|
+
startActivity(intent);
|
354
|
+
|
355
|
+
}
|
356
|
+
|
357
|
+
}
|
358
|
+
|
359
|
+
});
|
324
360
|
|
325
361
|
}
|
326
362
|
|
363
|
+
|
364
|
+
|
327
|
-
|
365
|
+
//このメソッドを呼び出せば、PasswordとUserIdがセットされるようにする
|
366
|
+
|
367
|
+
|
368
|
+
|
328
|
-
|
369
|
+
public void NewUserSet() {
|
329
|
-
|
330
|
-
|
370
|
+
|
371
|
+
|
372
|
+
|
331
|
-
//
|
373
|
+
//NewUserAddというデータベースのクラス
|
374
|
+
|
332
|
-
|
375
|
+
final NCMBObject obj2 = new NCMBObject("NewUserAdd");
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
mUserName = (EditText) findViewById(R.id.UserName);//ユーザーが入力するUserName
|
380
|
+
|
381
|
+
mPassword = (EditText) findViewById(R.id.Password);//ユーザーが入力するPassword
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
String userName = mUserName.getText().toString();
|
386
|
+
|
387
|
+
String password = mPassword.getText().toString();
|
388
|
+
|
389
|
+
obj2.put("Password", password);
|
390
|
+
|
391
|
+
obj2.put("UserName", userName);
|
392
|
+
|
393
|
+
obj2.saveInBackground(new DoneCallback() {
|
394
|
+
|
333
|
-
@Override
|
395
|
+
@Override
|
334
|
-
|
335
|
-
|
396
|
+
|
336
|
-
|
337
|
-
//そのログインページはMainActivityだから、ActivityThirdはいらない。
|
338
|
-
|
339
|
-
public void onC
|
397
|
+
public void done(NCMBException e) {
|
340
|
-
|
398
|
+
|
341
|
-
if (
|
399
|
+
if (e != null) {
|
342
|
-
|
400
|
+
|
343
|
-
//
|
401
|
+
//保存失敗
|
344
|
-
|
402
|
+
|
345
|
-
|
403
|
+
new AlertDialog.Builder(ActivitySecond.this)
|
404
|
+
|
346
|
-
|
405
|
+
.setTitle("Notification from Nifty")
|
406
|
+
|
407
|
+
.setMessage("Error:" + e.getMessage())
|
408
|
+
|
409
|
+
.setPositiveButton("OK", null)
|
410
|
+
|
411
|
+
.show();
|
412
|
+
|
413
|
+
} else {
|
414
|
+
|
415
|
+
//保存成功
|
416
|
+
|
347
|
-
|
417
|
+
new AlertDialog.Builder(ActivitySecond.this)
|
418
|
+
|
348
|
-
|
419
|
+
.setTitle("Notification from Nifty")
|
420
|
+
|
421
|
+
.setMessage("Save successfull! with ID:" + obj2.getObjectId())
|
422
|
+
|
423
|
+
.setPositiveButton("OK", null)
|
424
|
+
|
425
|
+
.show();
|
426
|
+
|
349
|
-
}
|
427
|
+
}
|
428
|
+
|
350
|
-
|
429
|
+
}
|
430
|
+
|
351
|
-
|
431
|
+
});
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
432
|
|
357
433
|
}
|
358
434
|
|
359
|
-
// });
|
360
|
-
|
361
|
-
// }
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
//このメソッドを呼び出せば、PasswordとUserIdがセットされるようにする。
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
public void NewUserSet() {
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
//NewUserAddというデータベースのクラス
|
376
|
-
|
377
|
-
final NCMBObject obj2 = new NCMBObject("NewUserAdd");
|
378
|
-
|
379
|
-
//ここをPlanText(TextView)にユーザーが打ち込んだ値にする。
|
380
|
-
|
381
|
-
//Buttonと同様にEditTextをインスタンス化し、EditTextから文字列を取得してください。
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
//ここに新しく上で宣言した、UserNameとPasswordを(XMLのViewを)取得する。
|
386
|
-
|
387
|
-
//この下のR.id.UserNameのところには、何書くべきなのか?
|
388
|
-
|
389
|
-
mUserName=(EditText)findViewById(R.id.UserName);//ユーザーが入力するUserName
|
390
|
-
|
391
|
-
mPassword=(EditText)findViewById(R.id.Password);//ユーザーが入力するPassword
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
String userName=mUserName.getText().toString();
|
396
|
-
|
397
|
-
String password=mPassword.getText().toString();
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
obj2.put("Password", password);
|
402
|
-
|
403
|
-
obj2.put("UserName", userName);
|
404
|
-
|
405
|
-
obj2.saveInBackground(new DoneCallback() {
|
406
|
-
|
407
|
-
@Override
|
408
|
-
|
409
|
-
public void done(NCMBException e) {
|
410
|
-
|
411
|
-
if (e != null) {
|
412
|
-
|
413
|
-
//保存失敗
|
414
|
-
|
415
|
-
new AlertDialog.Builder(ActivitySecond.this)
|
416
|
-
|
417
|
-
.setTitle("Notification from Nifty")
|
418
|
-
|
419
|
-
.setMessage("Error:" + e.getMessage())
|
420
|
-
|
421
|
-
.setPositiveButton("OK", null)
|
422
|
-
|
423
|
-
.show();
|
424
|
-
|
425
|
-
} else {
|
426
|
-
|
427
|
-
//保存成功
|
428
|
-
|
429
|
-
new AlertDialog.Builder(ActivitySecond.this)
|
430
|
-
|
431
|
-
.setTitle("Notification from Nifty")
|
432
|
-
|
433
|
-
.setMessage("Save successfull! with ID:" + obj2.getObjectId())
|
434
|
-
|
435
|
-
.setPositiveButton("OK", null)
|
436
|
-
|
437
|
-
.show();
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
//ここにActivityの変更を入れればいきなり成功したらログイン画面のActivityThirdにいける
|
444
|
-
|
445
|
-
//Button newUserSetButton=(Button)findViewById(R.id.NewUserSet);
|
446
|
-
|
447
|
-
// newUserSetButton.setOnClickListener(new View.OnClickListener(){
|
448
|
-
|
449
|
-
//onCreateに移動
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
//ここにログインへのボタンを押した時を作る
|
454
|
-
|
455
|
-
@Override
|
456
|
-
|
457
|
-
public void onClick(View v) {
|
458
|
-
|
459
|
-
//本当はThirdに行くのはToLoginだけどこの場合はNewUserSet
|
460
|
-
|
461
|
-
if (v.getId() == R.id.NewUserSet) {
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
Intent intent = new Intent(getApplication(), ActivityThird.class);
|
468
|
-
|
469
|
-
startActivity(intent);
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
}
|
476
|
-
|
477
|
-
}
|
478
|
-
|
479
|
-
// });
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
}
|
490
|
-
|
491
|
-
}
|
492
|
-
|
493
|
-
});
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
}
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
435
|
}
|
512
436
|
|
513
437
|
|
@@ -516,4 +440,18 @@
|
|
516
440
|
|
517
441
|
|
518
442
|
|
443
|
+
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
|
456
|
+
|
519
457
|
```
|
7
コードの変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -238,11 +238,105 @@
|
|
238
238
|
|
239
239
|
```
|
240
240
|
|
241
|
-
|
241
|
+
8:08分のActivitySecond.java
|
242
242
|
|
243
243
|
```java
|
244
244
|
|
245
|
+
package ncmbdataquick.mbaas.com.nifty.datastorequickstart;
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
import android.app.Activity;
|
250
|
+
|
251
|
+
import android.app.AlertDialog;
|
252
|
+
|
253
|
+
import android.content.Intent;
|
254
|
+
|
255
|
+
import android.os.Bundle;
|
256
|
+
|
257
|
+
import android.support.design.widget.FloatingActionButton;
|
258
|
+
|
259
|
+
import android.support.design.widget.Snackbar;
|
260
|
+
|
261
|
+
import android.support.v7.app.AppCompatActivity;
|
262
|
+
|
263
|
+
import android.support.v7.widget.Toolbar;
|
264
|
+
|
265
|
+
import android.view.View;
|
266
|
+
|
267
|
+
import android.widget.Button;
|
268
|
+
|
269
|
+
import android.widget.EditText;
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
import com.nifty.cloud.mb.core.DoneCallback;
|
274
|
+
|
275
|
+
import com.nifty.cloud.mb.core.NCMB;
|
276
|
+
|
277
|
+
import com.nifty.cloud.mb.core.NCMBException;
|
278
|
+
|
279
|
+
import com.nifty.cloud.mb.core.NCMBObject;
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
import javax.security.auth.callback.PasswordCallback;
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
public class ActivitySecond extends Activity {
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
//変数を宣言する
|
292
|
+
|
293
|
+
private EditText mUserName;
|
294
|
+
|
295
|
+
private EditText mPassword;
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
@Override
|
302
|
+
|
303
|
+
protected void onCreate(Bundle savedInstanceState) {
|
304
|
+
|
305
|
+
super.onCreate(savedInstanceState);
|
306
|
+
|
307
|
+
setContentView(R.layout.activity_activity_second);
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
//**************** APIキーの設定とSDKの初期化 **********************
|
314
|
+
|
315
|
+
NCMB.initialize(this, "78da4765984f7add2ddd2b22ed978d4bf744818563c44fbdd0f3be19b7430a43", "bce814b5040d532d488c176b114fa3463552c10d9e226b9090dbe959b2f0dc46");
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
Button sendButton = (Button) findViewById(R.id.ToLogin);
|
322
|
+
|
323
|
+
sendButton.setOnClickListener(this);
|
324
|
+
|
325
|
+
}
|
326
|
+
|
327
|
+
//{
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
//ここに新規登録へのボタンを押した時を作る
|
332
|
+
|
333
|
+
@Override
|
334
|
+
|
335
|
+
//登録ボタンを押したら、登録完了のポップを出しログインへボタンを押しログインページに戻るようにする。
|
336
|
+
|
337
|
+
//そのログインページはMainActivityだから、ActivityThirdはいらない。
|
338
|
+
|
245
|
-
public void onClick(View v) {
|
339
|
+
public void onClick(View v) {
|
246
340
|
|
247
341
|
if (v.getId() == R.id.ToLogin) {
|
248
342
|
|
@@ -252,40 +346,174 @@
|
|
252
346
|
|
253
347
|
startActivity(intent);
|
254
348
|
|
255
|
-
|
256
|
-
|
257
|
-
//View viewを無くしたこれは多分表示するページだと思う.
|
258
|
-
|
259
|
-
//だから、activity_activity_secondだと思う。
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
} else if (v.getId() == R.id.NewUserSet) {
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
this.NewUserSet(R.layout.activity_activity_second);
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
//このメソッドを呼び出せば、PasswordとUserIdがセットされるようにする。
|
282
|
-
|
283
|
-
// this.NewUserSet(R.id_content_activity_third);
|
284
|
-
|
285
349
|
}
|
286
350
|
|
351
|
+
//これはログイン専用ページ
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
|
287
357
|
}
|
288
358
|
|
359
|
+
// });
|
360
|
+
|
361
|
+
// }
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
//このメソッドを呼び出せば、PasswordとUserIdがセットされるようにする。
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
public void NewUserSet() {
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
//NewUserAddというデータベースのクラス
|
376
|
+
|
377
|
+
final NCMBObject obj2 = new NCMBObject("NewUserAdd");
|
378
|
+
|
379
|
+
//ここをPlanText(TextView)にユーザーが打ち込んだ値にする。
|
380
|
+
|
381
|
+
//Buttonと同様にEditTextをインスタンス化し、EditTextから文字列を取得してください。
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
//ここに新しく上で宣言した、UserNameとPasswordを(XMLのViewを)取得する。
|
386
|
+
|
387
|
+
//この下のR.id.UserNameのところには、何書くべきなのか?
|
388
|
+
|
389
|
+
mUserName=(EditText)findViewById(R.id.UserName);//ユーザーが入力するUserName
|
390
|
+
|
391
|
+
mPassword=(EditText)findViewById(R.id.Password);//ユーザーが入力するPassword
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
String userName=mUserName.getText().toString();
|
396
|
+
|
397
|
+
String password=mPassword.getText().toString();
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
obj2.put("Password", password);
|
402
|
+
|
403
|
+
obj2.put("UserName", userName);
|
404
|
+
|
405
|
+
obj2.saveInBackground(new DoneCallback() {
|
406
|
+
|
407
|
+
@Override
|
408
|
+
|
409
|
+
public void done(NCMBException e) {
|
410
|
+
|
411
|
+
if (e != null) {
|
412
|
+
|
413
|
+
//保存失敗
|
414
|
+
|
415
|
+
new AlertDialog.Builder(ActivitySecond.this)
|
416
|
+
|
417
|
+
.setTitle("Notification from Nifty")
|
418
|
+
|
419
|
+
.setMessage("Error:" + e.getMessage())
|
420
|
+
|
421
|
+
.setPositiveButton("OK", null)
|
422
|
+
|
423
|
+
.show();
|
424
|
+
|
425
|
+
} else {
|
426
|
+
|
427
|
+
//保存成功
|
428
|
+
|
429
|
+
new AlertDialog.Builder(ActivitySecond.this)
|
430
|
+
|
431
|
+
.setTitle("Notification from Nifty")
|
432
|
+
|
433
|
+
.setMessage("Save successfull! with ID:" + obj2.getObjectId())
|
434
|
+
|
435
|
+
.setPositiveButton("OK", null)
|
436
|
+
|
437
|
+
.show();
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
//ここにActivityの変更を入れればいきなり成功したらログイン画面のActivityThirdにいける
|
444
|
+
|
445
|
+
//Button newUserSetButton=(Button)findViewById(R.id.NewUserSet);
|
446
|
+
|
447
|
+
// newUserSetButton.setOnClickListener(new View.OnClickListener(){
|
448
|
+
|
449
|
+
//onCreateに移動
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
//ここにログインへのボタンを押した時を作る
|
454
|
+
|
455
|
+
@Override
|
456
|
+
|
457
|
+
public void onClick(View v) {
|
458
|
+
|
459
|
+
//本当はThirdに行くのはToLoginだけどこの場合はNewUserSet
|
460
|
+
|
461
|
+
if (v.getId() == R.id.NewUserSet) {
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
Intent intent = new Intent(getApplication(), ActivityThird.class);
|
468
|
+
|
469
|
+
startActivity(intent);
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
|
474
|
+
|
475
|
+
}
|
476
|
+
|
477
|
+
}
|
478
|
+
|
479
|
+
// });
|
480
|
+
|
481
|
+
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
|
486
|
+
|
487
|
+
|
488
|
+
|
489
|
+
}
|
490
|
+
|
491
|
+
}
|
492
|
+
|
493
|
+
});
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
|
498
|
+
|
499
|
+
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
|
504
|
+
|
505
|
+
}
|
506
|
+
|
507
|
+
|
508
|
+
|
509
|
+
|
510
|
+
|
511
|
+
}
|
512
|
+
|
513
|
+
|
514
|
+
|
515
|
+
|
516
|
+
|
289
517
|
|
290
518
|
|
291
519
|
```
|
6
コードの詳細
test
CHANGED
File without changes
|
test
CHANGED
@@ -270,9 +270,9 @@
|
|
270
270
|
|
271
271
|
|
272
272
|
|
273
|
-
|
273
|
+
|
274
|
-
|
275
|
-
|
274
|
+
|
275
|
+
|
276
276
|
|
277
277
|
|
278
278
|
|
5
コードの変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -242,164 +242,50 @@
|
|
242
242
|
|
243
243
|
```java
|
244
244
|
|
245
|
+
public void onClick(View v) {
|
246
|
+
|
247
|
+
if (v.getId() == R.id.ToLogin) {
|
248
|
+
|
249
|
+
//この下をclassをログインページに変更する。Activityをもう一つ作る。
|
250
|
+
|
245
|
-
|
251
|
+
Intent intent = new Intent(getApplication(), ActivityThird.class);
|
252
|
+
|
246
|
-
|
253
|
+
startActivity(intent);
|
247
|
-
|
248
|
-
|
254
|
+
|
255
|
+
|
256
|
+
|
249
|
-
//
|
257
|
+
//View viewを無くしたこれは多分表示するページだと思う.
|
250
|
-
|
251
|
-
|
258
|
+
|
252
|
-
|
253
|
-
|
259
|
+
//だから、activity_activity_secondだと思う。
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
+
|
260
|
-
|
261
|
+
|
262
|
+
|
261
|
-
|
263
|
+
} else if (v.getId() == R.id.NewUserSet) {
|
262
|
-
|
263
|
-
|
264
|
+
|
264
|
-
|
265
|
+
|
266
|
+
|
265
|
-
se
|
267
|
+
this.NewUserSet(R.layout.activity_activity_second);
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
266
|
-
|
273
|
+
// });
|
274
|
+
|
267
|
-
|
275
|
+
// }
|
268
|
-
|
269
|
-
|
270
|
-
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
|
271
|
-
//
|
281
|
+
//このメソッドを呼び出せば、PasswordとUserIdがセットされるようにする。
|
272
|
-
|
273
|
-
|
282
|
+
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
findViewById(R.id.ToLogin).setOnClickListener(this);
|
278
|
-
|
279
|
-
|
283
|
+
// this.NewUserSet(R.id_content_activity_third);
|
284
|
+
|
280
|
-
|
285
|
+
}
|
281
|
-
|
282
286
|
|
283
287
|
}
|
284
288
|
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
//ここに新規登録へのボタンを押した時を作る
|
290
|
-
|
291
|
-
@Override
|
292
|
-
|
293
|
-
//登録ボタンを押したら、登録完了のポップを出しログインへボタンを押しログインページに戻るようにする。
|
294
|
-
|
295
|
-
//そのログインページはMainActivityだから、ActivityThirdはいらない。
|
296
|
-
|
297
|
-
public void onClick(View v) {
|
298
|
-
|
299
|
-
//この下をclassをログインページに変更する。Activityをもう一つ作る。
|
300
|
-
|
301
|
-
Intent intent = new Intent(getApplication(), ActivityThird.class);
|
302
|
-
|
303
|
-
startActivity(intent);
|
304
|
-
|
305
|
-
}
|
306
|
-
|
307
|
-
//これはログイン専用ページ
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
//このメソッドを呼び出せば、PasswordとUserIdがセットされるようにする。
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
public void NewUserSet(View view) {
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
//NewUserAddというデータベースのクラス
|
322
|
-
|
323
|
-
final NCMBObject obj2 = new NCMBObject("NewUserAdd");
|
324
|
-
|
325
|
-
//ここをPlanText(TextView)にユーザーが打ち込んだ値にする。
|
326
|
-
|
327
|
-
//Buttonと同様にEditTextをインスタンス化し、EditTextから文字列を取得してください。
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
//ここに新しく上で宣言した、UserNameとPasswordを(XMLのViewを)取得する。
|
332
|
-
|
333
|
-
//この下のR.id.UserNameのところには、何書くべきなのか?
|
334
|
-
|
335
|
-
mUserName=(EditText)findViewById(R.id.UserName);//ユーザーが入力するUserName
|
336
|
-
|
337
|
-
mPassword=(EditText)findViewById(R.id.Password);//ユーザーが入力するPassword
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
String userName=mUserName.getText().toString();
|
342
|
-
|
343
|
-
String password=mPassword.getText().toString();
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
obj2.put("Password", password);
|
348
|
-
|
349
|
-
obj2.put("UserName", userName);
|
350
|
-
|
351
|
-
obj2.saveInBackground(new DoneCallback() {
|
352
|
-
|
353
|
-
@Override
|
354
|
-
|
355
|
-
public void done(NCMBException e) {
|
356
|
-
|
357
|
-
if (e != null) {
|
358
|
-
|
359
|
-
//保存失敗
|
360
|
-
|
361
|
-
new AlertDialog.Builder(ActivitySecond.this)
|
362
|
-
|
363
|
-
.setTitle("Notification from Nifty")
|
364
|
-
|
365
|
-
.setMessage("Error:" + e.getMessage())
|
366
|
-
|
367
|
-
.setPositiveButton("OK", null)
|
368
|
-
|
369
|
-
.show();
|
370
|
-
|
371
|
-
} else {
|
372
|
-
|
373
|
-
//保存成功
|
374
|
-
|
375
|
-
new AlertDialog.Builder(ActivitySecond.this)
|
376
|
-
|
377
|
-
.setTitle("Notification from Nifty")
|
378
|
-
|
379
|
-
.setMessage("Save successfull! with ID:" + obj2.getObjectId())
|
380
|
-
|
381
|
-
.setPositiveButton("OK", null)
|
382
|
-
|
383
|
-
.show();
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
//ここにActivityの変更を入れればいきなり成功したらログイン画面のActivityThirdにいける
|
388
|
-
|
389
|
-
Intent intent = new Intent(getApplication(), ActivityThird.class);
|
390
|
-
|
391
|
-
startActivity(intent);
|
392
|
-
|
393
|
-
}
|
394
|
-
|
395
|
-
}
|
396
|
-
|
397
|
-
});
|
398
|
-
|
399
|
-
}
|
400
|
-
|
401
|
-
}
|
402
|
-
|
403
289
|
|
404
290
|
|
405
291
|
```
|
4
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -237,3 +237,169 @@
|
|
237
237
|
|
238
238
|
|
239
239
|
```
|
240
|
+
|
241
|
+
改善後のActivitySecond.java
|
242
|
+
|
243
|
+
```java
|
244
|
+
|
245
|
+
public class ActivitySecond extends Activity implements View.OnClickListener {
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
//変数を宣言する
|
250
|
+
|
251
|
+
private EditText mUserName;
|
252
|
+
|
253
|
+
private EditText mPassword;
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
@Override
|
260
|
+
|
261
|
+
protected void onCreate(Bundle savedInstanceState) {
|
262
|
+
|
263
|
+
super.onCreate(savedInstanceState);
|
264
|
+
|
265
|
+
setContentView(R.layout.activity_activity_second);
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
//**************** APIキーの設定とSDKの初期化 **********************
|
272
|
+
|
273
|
+
NCMB.initialize(this, "");
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
findViewById(R.id.ToLogin).setOnClickListener(this);
|
278
|
+
|
279
|
+
findViewById(R.id.NewUserSet).setOnClickListener(this);
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
}
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
//ここに新規登録へのボタンを押した時を作る
|
290
|
+
|
291
|
+
@Override
|
292
|
+
|
293
|
+
//登録ボタンを押したら、登録完了のポップを出しログインへボタンを押しログインページに戻るようにする。
|
294
|
+
|
295
|
+
//そのログインページはMainActivityだから、ActivityThirdはいらない。
|
296
|
+
|
297
|
+
public void onClick(View v) {
|
298
|
+
|
299
|
+
//この下をclassをログインページに変更する。Activityをもう一つ作る。
|
300
|
+
|
301
|
+
Intent intent = new Intent(getApplication(), ActivityThird.class);
|
302
|
+
|
303
|
+
startActivity(intent);
|
304
|
+
|
305
|
+
}
|
306
|
+
|
307
|
+
//これはログイン専用ページ
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
//このメソッドを呼び出せば、PasswordとUserIdがセットされるようにする。
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
public void NewUserSet(View view) {
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
//NewUserAddというデータベースのクラス
|
322
|
+
|
323
|
+
final NCMBObject obj2 = new NCMBObject("NewUserAdd");
|
324
|
+
|
325
|
+
//ここをPlanText(TextView)にユーザーが打ち込んだ値にする。
|
326
|
+
|
327
|
+
//Buttonと同様にEditTextをインスタンス化し、EditTextから文字列を取得してください。
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
//ここに新しく上で宣言した、UserNameとPasswordを(XMLのViewを)取得する。
|
332
|
+
|
333
|
+
//この下のR.id.UserNameのところには、何書くべきなのか?
|
334
|
+
|
335
|
+
mUserName=(EditText)findViewById(R.id.UserName);//ユーザーが入力するUserName
|
336
|
+
|
337
|
+
mPassword=(EditText)findViewById(R.id.Password);//ユーザーが入力するPassword
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
String userName=mUserName.getText().toString();
|
342
|
+
|
343
|
+
String password=mPassword.getText().toString();
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
obj2.put("Password", password);
|
348
|
+
|
349
|
+
obj2.put("UserName", userName);
|
350
|
+
|
351
|
+
obj2.saveInBackground(new DoneCallback() {
|
352
|
+
|
353
|
+
@Override
|
354
|
+
|
355
|
+
public void done(NCMBException e) {
|
356
|
+
|
357
|
+
if (e != null) {
|
358
|
+
|
359
|
+
//保存失敗
|
360
|
+
|
361
|
+
new AlertDialog.Builder(ActivitySecond.this)
|
362
|
+
|
363
|
+
.setTitle("Notification from Nifty")
|
364
|
+
|
365
|
+
.setMessage("Error:" + e.getMessage())
|
366
|
+
|
367
|
+
.setPositiveButton("OK", null)
|
368
|
+
|
369
|
+
.show();
|
370
|
+
|
371
|
+
} else {
|
372
|
+
|
373
|
+
//保存成功
|
374
|
+
|
375
|
+
new AlertDialog.Builder(ActivitySecond.this)
|
376
|
+
|
377
|
+
.setTitle("Notification from Nifty")
|
378
|
+
|
379
|
+
.setMessage("Save successfull! with ID:" + obj2.getObjectId())
|
380
|
+
|
381
|
+
.setPositiveButton("OK", null)
|
382
|
+
|
383
|
+
.show();
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
//ここにActivityの変更を入れればいきなり成功したらログイン画面のActivityThirdにいける
|
388
|
+
|
389
|
+
Intent intent = new Intent(getApplication(), ActivityThird.class);
|
390
|
+
|
391
|
+
startActivity(intent);
|
392
|
+
|
393
|
+
}
|
394
|
+
|
395
|
+
}
|
396
|
+
|
397
|
+
});
|
398
|
+
|
399
|
+
}
|
400
|
+
|
401
|
+
}
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
```
|
3
誤字
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Androidアプリで2つのonClick()をif文で判断し、その片方はif文の結果によってActivityを変更するかを決めたいです。
|
1
|
+
Androidアプリで2つのonClick()をif文で判断し、その片方は、別の保存が成功したかのif文の結果によってActivityを変更するかを決めたいです。
|
test
CHANGED
File without changes
|
2
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -182,7 +182,7 @@
|
|
182
182
|
|
183
183
|
|
184
184
|
|
185
|
-
//こ
|
185
|
+
//この下のonClickがNewUserSetボタンが押された時に起動するようにしたい
|
186
186
|
|
187
187
|
@Override
|
188
188
|
|
1
脱字
test
CHANGED
File without changes
|
test
CHANGED
@@ -66,13 +66,13 @@
|
|
66
66
|
|
67
67
|
//登録ボタンを押したら、登録完了のポップを出しログインへボタンを押しログインページに戻るようにする。
|
68
68
|
|
69
|
-
|
69
|
+
|
70
70
|
|
71
71
|
public void onClick(View v) {
|
72
72
|
|
73
73
|
if (v.getId() == R.id.ToLogin) {
|
74
74
|
|
75
|
-
//この下
|
75
|
+
//この下のclassはログインページ
|
76
76
|
|
77
77
|
Intent intent = new Intent(getApplication(), ActivityThird.class);
|
78
78
|
|
@@ -80,7 +80,7 @@
|
|
80
80
|
|
81
81
|
}
|
82
82
|
|
83
|
-
|
83
|
+
|
84
84
|
|
85
85
|
|
86
86
|
|