글쎄, 내 안드로이드 응용 프로그램에서 매우 구체적이고 어색한 문제가 있습니다. 이것은 서비스 클래스에서 onStartCommand 메소드 일 뿐이며, 실행될 때 전화 상태 수신기를 생성해야합니다. 따라서 사용자가 전화를받을 때마다 Parse에서 해당 번호를 내 데이터베이스로 보내려고합니다. 문제는 내부 클래스와 Parse에 충돌이 있다고 생각합니다. 아무것도 서버에 푸시되지 않습니다. 나는 안드로이드와 파스를 상당히 처음 사용하고 있기 때문에 뭔가 명확하지 않거나 해결 방법이 있다면 알려주도록한다. 감사구문 분석, 내부 클래스 및 전화 수신기
public int onStartCommand(Intent e, int flags, int startId) {
TelephonyManager TelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
class TeleListener extends PhoneStateListener {
public void onCallStateChanged(int state, String incomingNumber) {
super.onCallStateChanged(state, incomingNumber);
Parse.initialize(ParseService.this,
"still a secret",
"no no no");
PushService.setDefaultPushCallback(ParseService.this,
Main.class);
TelephonyManager TelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String userNumber = (String) TelephonyMgr.getLine1Number();
switch (state) {
case TelephonyManager.CALL_STATE_OFFHOOK:
// OFFHOOK
ParseObject Users = new ParseObject("UserCalls");
Users.put("CallsReceived", incomingNumber);
Users.put("UserNumber", userNumber);
Users.saveInBackground();
Toast.makeText(getApplicationContext(), "Offhook",
Toast.LENGTH_SHORT).show();
}
}
}
TelephonyMgr.listen(new TeleListener(),
PhoneStateListener.LISTEN_CALL_STATE);
Toast.makeText(this, "Service has Started", Toast.LENGTH_SHORT).show();
return START_STICKY;
}
일부 로그를 추가하십시오. 또한 사용자 클래스는 문자열 형식의 "_User"입니다. – Fosco