小编Kan*_*ngh的帖子

Android:如何知道MediaPlayer是否暂停?

MediaPlayer.isPlaying()不允许知道MediaPlayer是停止还是暂停.如何知道它是否暂停而未停止?

谢谢 !

java android stream media-player android-mediaplayer

16
推荐指数
2
解决办法
9846
查看次数

Java HTTPUrlConnection超时不起作用

我编写了一个程序,通过随机代理打开httpurlconnection到网站.我的httpurlconnection叫做conn.现在我知道,这其中的一些代理的可能太慢,所以我已经设置与连接至40000毫秒的超时conn.setConnectTimeout(40000)conn.setReadTimeout(40000).

这样做后,我得到了这段代码:

long diff = 0;
    long starttime = 0;
    long endtime = 0;

    try
    {
        starttime = System.currentTimeMillis();
        conn.connect();

        endtime = System.currentTimeMillis();

        diff = endtime - starttime;

        if (endtime <= starttime + conn.getConnectTimeout())
        {
            //Trying to read sourecode
            InputStreamReader isrConn = new InputStreamReader(conn.getInputStream());
            BufferedReader brConn = new BufferedReader(isrConn);

            line = brConn.readLine();

            while (line != null)
            {

                response += line + "\t";
                try
                {
                    line = brConn.readLine();
                } catch (IOException e)
                {
                    printError("Reading sourcecode …
Run Code Online (Sandbox Code Playgroud)

java timeout urlconnection httpurlconnection

10
推荐指数
2
解决办法
6078
查看次数

Android:通过意图与身体发送短信并返回.

我试图通过意图发送短信,我想在消息中添加一个正文.用户按下后send我想返回应用程序.我添加了额外的sms_bodyexit_on_sent.但是当我使用它们时,短信出现时没有身体.如果我不使用exit_on_sent额外的一切工作正常.

    Intent sendIntent = new Intent(Intent.ACTION_VIEW);         
    sendIntent.setData(Uri.parse("smsto:" + phoneNumber));
    sendIntent.putExtra("sms_body", "some text");
    sendIntent.putExtra("exit_on_sent", true);
    context.startActivity(sendIntent);
Run Code Online (Sandbox Code Playgroud)

android android-intent

8
推荐指数
1
解决办法
1499
查看次数

android模拟器无法启动

我正在尝试从Android虚拟设备管理器启动Android虚拟设备.将打开Android Emulator窗口,但屏幕仍保留在Android徽标上,并且不会继续进行.

它工作正常,直到开始第二个avd.现在第一个avd和第二个avd将无法启动.重启windows机但似乎没有效果.

windows android android-virtual-device

5
推荐指数
1
解决办法
7887
查看次数

从edittext android获取字符串是错误的

我是初学的android.我有从编辑视图中获取文本字符串的问题.请帮我修理一下.非常感谢.CommentActivity.java

public class CommentActivity extends Fragment  {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }
    TextView cmt;
    ArrayAdapter<String> adapter;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.comment_layout, container, false);
        Button send = (Button) v.findViewById(R.id.send_comment);
        cmt = (TextView) v.findViewById(R.id.text_comment);
        ListView lst = (ListView) v.findViewById(R.id.list_comments);
        String[] values = new String[] {};
        adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, android.R.id.text1, values);
        lst.setAdapter(adapter);
        send.setOnClickListener(new View.OnClickListener()
                {
               public void onClick(View v)
               {
                   CharSequence content = cmt.getText();
                   cmt.setText("");
                   adapter.add((String) content);
                   adapter.notifyDataSetChanged();
                   Toast.makeText(getActivity(), content, …
Run Code Online (Sandbox Code Playgroud)

android android-edittext

2
推荐指数
1
解决办法
4758
查看次数

java.lang.NoClassDefFoundError:com.google.gson.Gson

我是Android开发环境的新手,所以需要专家的帮助.

java.lang.NoClassDefFoundError: com.google.gson.Gson
Run Code Online (Sandbox Code Playgroud)

Gson库包含在项目中,但是当从项目内部的方法调用Gson时会得到类似的错误

android json gson

1
推荐指数
1
解决办法
2万
查看次数

如何在android中的TableLayout中将第一列设置为空,第二列包含按钮

我正在设计一个登录页面,其中包含EditText用户TextView名和密码以及用于登录和重置的按钮。我需要将按钮放在一列中,以便第一列应为空,第二列应有 2 个按钮。谁能帮我。

提前致谢。

这是我的 xml 代码。

<TableLayout
    android:id="@+id/con1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="25pt"
    android:layout_marginRight="25pt"
    android:gravity="center"
    android:orientation="vertical" >
    <TableRow android:layout_width="match_parent" android:gravity="center">

    <TextView
        android:id="@+id/lbl_heading"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_x="76px"
        android:layout_y="24px"
        android:text="SignIn Here"
        android:gravity="center" 
      >
    </TextView>
    </TableRow>

    <TableRow android:layout_width="fill_parent">


    <TextView
        android:id="@+id/lbl_username"
        android:layout_width="20pt"
        android:layout_height="wrap_content"
        android:layout_x="19px"
        android:layout_y="57px"
        android:gravity="left"
        android:text="Username" 
          android:layout_weight="0.5">

    </TextView>

    <EditText
        android:id="@+id/txt_username"
        android:layout_width="20pt"
        android:layout_height="wrap_content"
        android:layout_x="54px"
        android:layout_y="80px"
        android:textSize="18sp" 
          android:layout_weight="0.5">
    </EditText>
    </TableRow>

    <TableRow>

    <TextView
        android:id="@+id/lbl_password"
        android:layout_width="20pt"
        android:layout_height="wrap_content"
        android:layout_x="21px"
        android:layout_y="131px"
        android:text="Password" 
          android:layout_weight="0.5">
    </TextView>

    <EditText
        android:id="@+id/txt_password"
        android:layout_width="20pt"
        android:layout_height="47px"
        android:layout_x="53px"
        android:layout_y="155px"
        android:password="true"
        android:textSize="18sp" 
          android:layout_weight="0.5">
    </EditText>
    </TableRow>

    <TableRow>

    <LinearLayout …
Run Code Online (Sandbox Code Playgroud)

android

0
推荐指数
1
解决办法
4078
查看次数