Я использую API com.android.internal.telephony. В том, что я назвал два абстрактных класса, они Call.java и Connection.java. Вы можете найти эти классы здесь http://hi-android.info/src/com/android/internal/telephony/Call.java.html и http://hi-android.info/src/com/android/internal/telephony/Connection.java.html для этих созданных подклассов какПолучение нулевого значения
Call myCall = new MyCall();
Connection myConn = new MyConnection();
мне нужно использовать метод getDisconnectCause из класса соединений, который является абстрактным методом, я так:
myConn = myCall.getEarliestConnection();
if(myConn == null){
System.out.println("myConn is null ******");
}else
{
Connection.DisconnectCause cause = myConn.getDisconnectCause();
System.out.println("value of cause ******"+cause);
}
Подкласса из Call.java является:
1. CallManager cm = CallManager.getInstance();
2. Phone.State state;
3.
4. public List<Connection> getConnections() {
5. state = cm.getState();
6. ringingCall = cm.getForegroundCalls();
7. System.out.println("**inside getConnections="+state);
8. System.out.println("**inside getConnections="+ringingCall);
9. if (ringingCall == null) {
10. System.out.println("**call is null***");
11. return emptyConnections;
12. }
13. else
14. {
15. System.out.println("**call is not null***");
16. return ((Call) ringingCall).getConnections();
17. }
18. @Override
19. public Phone getPhone() {
20. return null;
}
@Override
public void hangup() throws CallStateException {
}
@Override
public boolean isMultiparty() {
return false;
}
public Connection
getEarliestConnection() {
List l;
long time = Long.MAX_VALUE;
Connection c;
Connection earliest = null;
68. l = getConnections();
if (l == null) {
return null;
}else if (l.size() == 0)
{
return null;
}
for (int i = 0, s = l.size() ; i < s ; i++) {
c = (Connection) l.get(i);
long t;
t = c.getCreateTime();
if (t < time) {
earliest = c;
time = t;
}
}
return earliest;
}
}
AND the Connection.java subclass is:
class MyConnection extends Connection{
@Override
public void cancelPostDial() {
// TODO Auto-generated method stub
}
@Override
public String getAddress() {
// TODO Auto-generated method stub
return null;
}
@Override
public Call getCall() {
// TODO Auto-generated method stub
return null;
}
@Override
public long getConnectTime() {
// TODO Auto-generated method stub
return 0;
}
@Override
public long getCreateTime() {
// TODO Auto-generated method stub
return 0;
}
@Override
public DisconnectCause getDisconnectCause() {
// TODO Auto-generated method stub
return null;
}
@Override
public long getDisconnectTime() {
// TODO Auto-generated method stub
return 0;
}
@Override
public long getDurationMillis() {
// TODO Auto-generated method stub
return 0;
}
@Override
public long getHoldDurationMillis() {
// TODO Auto-generated method stub
return 0;
}
@Override
public int getNumberPresentation() {
// TODO Auto-generated method stub
return 0;
}
@Override
public PostDialState getPostDialState() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getRemainingPostDialString() {
// TODO Auto-generated method stub
return null;
}
@Override
public UUSInfo getUUSInfo() {
// TODO Auto-generated method stub
return null;
}
@Override
public void hangup() throws CallStateException {
// TODO Auto-generated method stub
}
@Override
public boolean isIncoming() {
// TODO Auto-generated method stub
return false;
}
@Override
public void proceedAfterWaitChar() {
// TODO Auto-generated method stub
}
@Override
public void proceedAfterWildChar(String arg0) {
// TODO Auto-generated method stub
}
@Override
public void separate() throws CallStateException {
// TODO Auto-generated method stub
}
}
EDIT 2 : I have edited line number 1 to 17. Plz check this. I am getting java.lang.ClassCastException: java.util.Collections error on Line No: 16 and Line No:68.
Может кто-нибудь помочь мне решить эту проблему. А также я получаю только одно состояние вызова, то есть IDLE всегда, даже если вызов не равен-null. Я получаю внутри еще часть. PLZ помочь мне.
Тогда что мне делать? как реализовать метод getConnections. PLZ помочь мне. Thx заблаговременно – shiv1229
Я подозреваю, что существуют реализации Connection and Call, которые вы можете использовать вместо того, чтобы создавать свои собственные попытки поиска в Google. – James
Если бы вы быстро посмотрели, я 'com.android.internal.telephony.CallManager' может хранить то, что вы ищете , – James