私は、ユーザーが電話番号をボックスに入力してから連絡先を検索するアクティビティを開始するボタンを押して、入力された電話番号と一致する連絡先名を返すことができる単純なアプリケーションを作成しました。アプリケーションは強制終了します
ただし、アプリは強制終了します。ここで
コード
package com.xenom.text;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract.PhoneLookup;
import android.util.Log;
import android.view.View;
public class DriveAndTextActivity extends Activity
{
private View button1;
private String Text1;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button1.setOnClickListener(new View.OnClickListener() {
private String TAG;
public void onClick(View v) {
Log.d(TAG, "mbutton1 clicked");
Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(Text1));
resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME});
}
});
}
}
新しいコード
package com.xenom.text;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract.PhoneLookup;
import android.util.Log;
import android.view.View;
import android.widget.Button;
public class DriveAndTextActivity extends Activity
{
private Button mbutton1;
private String mText1;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Obtain handles to UI objects
mbutton1 = (Button) findViewById(R.id.button1);
mbutton1.setOnClickListener(new View.OnClickListener() {
private String TAG;
public void onClick(View v) {
Log.d(TAG, "mbutton1 clicked");
Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(mText1));
resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME});
}
});
}
}
がlogcatである:あなたがbutton1
インスタンスをインスタンス化している
[2011-07-27 22:43:56 - ddmlib]An established connection was aborted by the software in your host machine
java.io.IOException: An established connection was aborted by the software in your host machine
at sun.nio.ch.SocketDispatcher.write0(Native Method)
at sun.nio.ch.SocketDispatcher.write(Unknown Source)
at sun.nio.ch.IOUtil.writeFromNativeBuffer(Unknown Source)
at sun.nio.ch.IOUtil.write(Unknown Source)
at sun.nio.ch.SocketChannelImpl.write(Unknown Source)
at com.android.ddmlib.JdwpPacket.writeAndConsume(JdwpPacket.java:213)
at com.android.ddmlib.Client.sendAndConsume(Client.java:574)
at com.android.ddmlib.HandleHeap.sendREAQ(HandleHeap.java:348)
at com.android.ddmlib.Client.requestAllocationStatus(Client.java:420)
at com.android.ddmlib.DeviceMonitor.createClient(DeviceMonitor.java:854)
at com.android.ddmlib.DeviceMonitor.openClient(DeviceMonitor.java:822)
at com.android.ddmlib.DeviceMonitor.processIncomingJdwpData(DeviceMonitor.java:781)
at com.android.ddmlib.DeviceMonitor.deviceClientMonitorLoop(DeviceMonitor.java:649)
at com.android.ddmlib.DeviceMonitor.access$100(DeviceMonitor.java:42)
at com.android.ddmlib.DeviceMonitor$3.run(DeviceMonitor.java:577)
[2011-07-27 22:43:56 - ddmlib]An established connection was aborted by the software in your host machine
java.io.IOException: An established connection was aborted by the software in your host machine
at sun.nio.ch.SocketDispatcher.write0(Native Method)
at sun.nio.ch.SocketDispatcher.write(Unknown Source)
at sun.nio.ch.IOUtil.writeFromNativeBuffer(Unknown Source)
at sun.nio.ch.IOUtil.write(Unknown Source)
at sun.nio.ch.SocketChannelImpl.write(Unknown Source)
at com.android.ddmlib.JdwpPacket.writeAndConsume(JdwpPacket.java:213)
at com.android.ddmlib.Client.sendAndConsume(Client.java:574)
at com.android.ddmlib.HandleHeap.sendREAQ(HandleHeap.java:348)
at com.android.ddmlib.Client.requestAllocationStatus(Client.java:420)
at com.android.ddmlib.DeviceMonitor.createClient(DeviceMonitor.java:854)
at com.android.ddmlib.DeviceMonitor.openClient(DeviceMonitor.java:822)
at com.android.ddmlib.DeviceMonitor.processIncomingJdwpData(DeviceMonitor.java:781)
at com.android.ddmlib.DeviceMonitor.deviceClientMonitorLoop(DeviceMonitor.java:649)
at com.android.ddmlib.DeviceMonitor.access$100(DeviceMonitor.java:42)
at com.android.ddmlib.DeviceMonitor$3.run(DeviceMonitor.java:577)
[2011-07-27 22:43:56 - ddmlib]An established connection was aborted by the software in your host machine
java.io.IOException: An established connection was aborted by the software in your host machine
at sun.nio.ch.SocketDispatcher.write0(Native Method)
at sun.nio.ch.SocketDispatcher.write(Unknown Source)
at sun.nio.ch.IOUtil.writeFromNativeBuffer(Unknown Source)
at sun.nio.ch.IOUtil.write(Unknown Source)
at sun.nio.ch.SocketChannelImpl.write(Unknown Source)
at com.android.ddmlib.JdwpPacket.writeAndConsume(JdwpPacket.java:213)
at com.android.ddmlib.Client.sendAndConsume(Client.java:574)
at com.android.ddmlib.HandleHeap.sendREAQ(HandleHeap.java:348)
at com.android.ddmlib.Client.requestAllocationStatus(Client.java:420)
at com.android.ddmlib.DeviceMonitor.createClient(DeviceMonitor.java:854)
at com.android.ddmlib.DeviceMonitor.openClient(DeviceMonitor.java:822)
at com.android.ddmlib.DeviceMonitor.processIncomingJdwpData(DeviceMonitor.java:781)
at com.android.ddmlib.DeviceMonitor.deviceClientMonitorLoop(DeviceMonitor.java:649)
at com.android.ddmlib.DeviceMonitor.access$100(DeviceMonitor.java:42)
at com.android.ddmlib.DeviceMonitor$3.run(DeviceMonitor.java:577)
[2011-07-27 22:43:56 - ddmlib]An established connection was aborted by the software in your host machine
java.io.IOException: An established connection was aborted by the software in your host machine
at sun.nio.ch.SocketDispatcher.write0(Native Method)
at sun.nio.ch.SocketDispatcher.write(Unknown Source)
at sun.nio.ch.IOUtil.writeFromNativeBuffer(Unknown Source)
at sun.nio.ch.IOUtil.write(Unknown Source)
at sun.nio.ch.SocketChannelImpl.write(Unknown Source)
at com.android.ddmlib.JdwpPacket.writeAndConsume(JdwpPacket.java:213)
at com.android.ddmlib.Client.sendAndConsume(Client.java:574)
at com.android.ddmlib.HandleHeap.sendREAQ(HandleHeap.java:348)
at com.android.ddmlib.Client.requestAllocationStatus(Client.java:420)
at com.android.ddmlib.DeviceMonitor.createClient(DeviceMonitor.java:854)
at com.android.ddmlib.DeviceMonitor.openClient(DeviceMonitor.java:822)
at com.android.ddmlib.DeviceMonitor.processIncomingJdwpData(DeviceMonitor.java:781)
at com.android.ddmlib.DeviceMonitor.deviceClientMonitorLoop(DeviceMonitor.java:649)
at com.android.ddmlib.DeviceMonitor.access$100(DeviceMonitor.java:42)
at com.android.ddmlib.DeviceMonitor$3.run(DeviceMonitor.java:577)
[2011-07-27 22:43:57 - ddmlib]An established connection was aborted by the software in your host machine
java.io.IOException: An established connection was aborted by the software in your host machine
at sun.nio.ch.SocketDispatcher.write0(Native Method)
at sun.nio.ch.SocketDispatcher.write(Unknown Source)
at sun.nio.ch.IOUtil.writeFromNativeBuffer(Unknown Source)
at sun.nio.ch.IOUtil.write(Unknown Source)
at sun.nio.ch.SocketChannelImpl.write(Unknown Source)
at com.android.ddmlib.JdwpPacket.writeAndConsume(JdwpPacket.java:213)
at com.android.ddmlib.Client.sendAndConsume(Client.java:574)
at com.android.ddmlib.HandleHeap.sendREAQ(HandleHeap.java:348)
at com.android.ddmlib.Client.requestAllocationStatus(Client.java:420)
at com.android.ddmlib.DeviceMonitor.createClient(DeviceMonitor.java:854)
at com.android.ddmlib.DeviceMonitor.openClient(DeviceMonitor.java:822)
at com.android.ddmlib.DeviceMonitor.deviceClientMonitorLoop(DeviceMonitor.java:618)
at com.android.ddmlib.DeviceMonitor.access$100(DeviceMonitor.java:42)
at com.android.ddmlib.DeviceMonitor$3.run(DeviceMonitor.java:577)
DDMSを実行して、これについてlogcatが言っていることを確認してください。私たちはあなたのエラーが何であるかをよく知っていないので、私たちはおそらく(実際に人々がこのサイトでそれを引き出すかもしれないという理由で)おそらくあなたを助けることができません。オリジナルのポストを関連するスタックトレース(logcatにある)のコピーで更新します。 – ninetwozero
ok ddms now – Aman
申し訳ありませんが、関連するlogcat出力を投稿したとは思いません。 'com.xenom.text'に関するいくつかの例外を探すことができますか? – ninetwozero