小编pra*_*gai的帖子

如何从活动中逐个显示通知提醒列表?

我是Android应用程序的新程序员我想从activity.i逐个显示多个通知已经实现了一个获取通知的方法如下

       public void myNotify(String message) {

    Log.v("my notification method","from GetNotification class");

    NotificationManager notificationManager = (NotificationManager)       getSystemService(NOTIFICATION_SERVICE);
    Notification notification = new Notification(R.drawable.icon,
            "check the notification", System.currentTimeMillis());
    // Hide the notification after its selected
    notification.flags |= Notification.FLAG_AUTO_CANCEL;

    Intent intent = new Intent(android.content.Intent.ACTION_VIEW,Uri.parse(""));
    PendingIntent activity = PendingIntent.getActivity(this, 0, intent, 0);
    notification.setLatestEventInfo(this, message,
            "for more info run ur app", activity);
    notification.number += 1;
    notificationManager.notify(0, notification);



}
Run Code Online (Sandbox Code Playgroud)

我已经使用字符串数组将通知显示为列表,显示以下代码用于显示通知

       String[] msg={"hai","how are you?","wer r u?","what is going on","how is this?","let we talk?","nothing is there","hahaha"}; 
    Thread rt=new …
Run Code Online (Sandbox Code Playgroud)

notifications android list

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

在Android中转到另一个屏幕时停止所有Toast消息

在此输入图像描述 在此输入图像描述

当我点击按钮时,我正在显示一个简单的Toast.我的问题是,当我多次点击一个按钮时,Toast消息会一直显示,直到我进入主屏幕.当我到达主屏幕并在相应的活动中杀死Toast消息时,我想停止Toast.我附上了截图.

我编写的代码如下:

public class Main extends Activity {

    Dialog d;
    Toast t;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        ((Button)findViewById(R.id.button1)).setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub

                t = Toast.makeText(Main.this, "you clicked on button!", Toast.LENGTH_LONG);
                t.show();
            }
        });
    }
    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
        t.cancel();
    }
}
Run Code Online (Sandbox Code Playgroud)

我该怎么做?

android toast

4
推荐指数
2
解决办法
6524
查看次数

请求专注于编辑文本

我在android应用程序中遇到了不同的问题.我按顺序采用了3个EditTexts.我的目的是当我在第一个editText上setOnClick时出现虚拟键盘.当我在虚拟键盘上单击下一个时,courser将显示在第二个EditText中.但我不应该在第二个editText中得到它的焦点,它应该专注于第三个EditText.我如何专注于第3版edittext?

请帮忙.

提前致谢.

android focus android-edittext

4
推荐指数
1
解决办法
3866
查看次数

如何从BroadcastReceiver类引发警报对话框?

我在Activity课堂上使用过计时器方法.在那个方法中,我有一个从Activity类到BroadcastReceiver类的意图.

BroadcastReceiver课程将使用后台每15分钟拨打一次AlarmManager.

当我打电话给BroadcastReceiver课时,我想提出一个AlertDialog.

public void timerMethod(){
    Intent intent = new Intent(Activity.this,
      BroadcastReceiverClass.class
    );

    PendingIntent sender = PendingIntent.getBroadcast(
      QualityCallActivity.this,0, intent, 0
    );

    // We want the alarm to go off 30 seconds from now.
    long firstTime = SystemClock.elapsedRealtime();

    AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE);
    am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
    firstTime, 60*1000, sender);
}
Run Code Online (Sandbox Code Playgroud)

BroadcastReceiverClass.java

public void onReceive(Context context, Intent intent)
{
    dialogMethod();
}
Run Code Online (Sandbox Code Playgroud)

我怎样才能提高一个AlertDialogBroadcastReceiver类从后台进程?

android broadcastreceiver

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

如何将数据写入xml文件并将该xml保存在android应用程序中

我是android应用程序的新开发人员.我想将数据写入xml文件.我的意思是我想更改xml file.i中的元素,标签,数据等内容,能够读取该文件中的xml文件,我想更改或修改并保存该xml文件.

我已经编写了示例应用程序来读取xml,如下所示

FileInputStream fstream = new FileInputStream("/sdcard/book.xml");
  BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
  String strLine;
  //Read File Line By Line
  while ((strLine = br.readLine()) != null)   {
  // Print the content on the console
  System.out.println ("Xml file content====>"+strLine);


  data1.append(strLine);
  data1.append('\n');


  System.out.println("--------->"+data1.append(strLine)+"\n");
Run Code Online (Sandbox Code Playgroud)

我已经在这里的方法中编写了这个代码,book.xml是我要更改的xml文件

当我调用这个方法然后我在logcat中输出标签,如下所示

06-14 12:48:32.309: VERBOSE/(433): #######>>>>><?xml version="1.0" encoding="utf-8"?>
06-14 12:48:32.309: VERBOSE/(433): <Employee-Detail>
06-14 12:48:32.309: VERBOSE/(433): <Employee>
06-14 12:48:32.309: VERBOSE/(433): <Emp_Id>E-001</Emp_Id>
06-14 12:48:32.309: VERBOSE/(433): <Emp_Name>Vinod</Emp_Name>
06-14 12:48:32.309: VERBOSE/(433): <Emp_E-mail>Vinod1@yahoo.com</Emp_E-mail>
06-14 12:48:32.309: VERBOSE/(433): </Employee>
06-14 12:48:32.309: VERBOSE/(433): <Employee> …
Run Code Online (Sandbox Code Playgroud)

xml android

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

如何获得android api 12级模拟器上的选项菜单?

我刚开始使用Android平板电脑api级别12.我创建了7英寸avd,1024*600屏幕分辨率.我已经实现了示例应用程序,以获取我的屏幕上的选项菜单和后退按钮.我无法看到选项按钮和我的模拟器上的后退按钮.

我已经实现了选项菜单代码,如下所示

  @Override
 public boolean onCreateOptionsMenu(Menu menu) {
     MenuInflater inflater = getMenuInflater();
     inflater.inflate(R.menu.menu, menu);

     return true;
 }


 @Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
    case R.id.icon:     Toast.makeText(this, "You pressed the icon!", Toast.LENGTH_LONG).show();
                        break;
    case R.id.text:     Toast.makeText(this, "You pressed the text!", Toast.LENGTH_LONG).show();
                        break;
    case R.id.icontext: Toast.makeText(this, "You pressed the icon and text!", Toast.LENGTH_LONG).show();
                        break;
    }

    return true;
}
Run Code Online (Sandbox Code Playgroud)

任何身体请帮助我.

android menu emulation option

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

如何从Service类更新SimpleCursorAdapter列表视图?

我已经用于SimpleCursorAdapter将数据显示在我的活动类的列表中.我正在获取data from Sqlite DB and applying to listview.我正在从服务类插入数据.在我的服务类中,我从WEB服务获取数据并将最新的数据插入到Sqlite移动数据库这项服务class将每隔5秒运行一次以检查最新的Web服务,然后将其带入并插入到Sqlite db中.当新记录插入Sqlite db时,listview不会使用最新插入的记录进行更新.我已经实现了我的应用程序如下:

MyActivity.java

private MySqliteHelper msh;
ListView lst;
Cursor cursor;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        msh = new MySqliteHelper(MyActivity.this);
        msh.openToWrite();
        lst = ((ListView)findViewById(R.id.listView1));
        cursor = msh.queueAll();

        String getFromDB[] = new String[]{MySqliteHelper.KEY_CONTENT1,MySqliteHelper.KEY_CONTENT2};
        int toView[] = new int[]{R.id.msgId,R.id.usrmsg};

        lst.setAdapter(new SimpleCursorAdapter(this, R.layout.list, cursor, getFromDB, toView));

       //calling service class
        bindService(new Intent(ShoutGetMessagesActivity.this, ShoutRepeatService.class), mConnection, Context.BIND_AUTO_CREATE);

        updateList();
    }

      private void updateList(){
              cursor.requery();
               }


        RepeatService bg;
        private ServiceConnection mConnection = new ServiceConnection() …
Run Code Online (Sandbox Code Playgroud)

sqlite service android background

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

如何在我的申请中获得拨打的手机号码?

可能重复:
拨打号码时启动我的应用程序

我想从我的Android应用程序中用户拨打的拨号器中获取手机号码.我已经实现了如下应用程序:

 ((Button)findViewById(R.id.button1)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
             startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:")));

        }
    });
Run Code Online (Sandbox Code Playgroud)

从上面的代码我可以打开拨号器app.如果用户输入手机号码并点击呼叫,那么我想得到他输入的号码.请任何身体帮助...

android phone-call phone-number

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