小编aps*_*109的帖子

如何将数据从广播接收器发送到android中的活动

这就是我想要做的.我创建了一个broadcastreceiver类,它通过callrecieve活动检测来电.现在,一旦来电,我想找到它的当前时间并通过另一个活动显示它.我用过这个意图.但是,当我接到电话时,我仍然无法获得所需的时间值.我已经发布了我正在使用的所有代码.任何帮助都会很棒

这是广播接收器活动,它检查电话的来电状态,并负责广播意图

package com.mohit;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.util.Log;


public class callreceive extends Activity {
public class receive extends BroadcastReceiver {


    long start_time,end_time,dif_sec;
    int flag=0;

  @Override
  public void onReceive(Context context, Intent intent) {
    Bundle extras = intent.getExtras();
    if (extras != null) {
      String state = extras.getString(TelephonyManager.EXTRA_STATE);

      Log.w("DEBUG", state);
      if ((state.equals(TelephonyManager.EXTRA_STATE_IDLE))&&flag==0) 
      {
        flag=1;
        start_time=System.currentTimeMillis();
        Intent intent1 = new Intent();//(callreceive.this,TestActivity.class);
        intent1.setAction(Intent.ACTION_SEND);
        intent1.putExtra("start_time",start_time);
        startActivity(intent1);

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

现在我想在执行循环后立即将start_time的值发送给活动.以下是接收活动 - 测试活动的代码.

package com.mohit; …
Run Code Online (Sandbox Code Playgroud)

android broadcastreceiver

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

可滚动的vaadin视图以显示页面中的所有组件

如何使用布局组件在vaadin中实现html网页(vaadin的新功能)

现在我在UI组件中添加的任何组件只有一些组件出现在浏览器中...

没有滚动选项可以查看我在层次结构中添加的其他组件

public class LoginView extends CustomComponent implements View,
    Button.ClickListener {

    public static final String NAME = "login";

    private TextField user;

    private PasswordField password;

    private Button loginButton;
    NativeSelect select_role;

    private HorizontalLayout fieldsBottomPanel;

    private VerticalLayout fieldsLeftPanel;

    private GridLayout loginPanelGrid;

    private VerticalLayout filedsTopPanel;

    private VerticalLayout loginFormLayout;

    private Label top_header_panel;

    private VerticalLayout virtualKeyboard;

    private VerticalLayout fieldsRightPanel;

    private VerticalLayout footer;

    private VerticalLayout header;

    private Window page;



    public LoginView() {
        setSizeFull();  
        addTopPanelToLoginForm();
        addLeftPanelToLoginForm();
        addBottomPanelToLoginForm();
        addRightPanelToLoginForm();
        addLoginFormToPage();
        addFooterToPage();
        addHeaderToPage();

        VerticalLayout viewLayout = new VerticalLayout(header,loginFormLayout,footer);
        viewLayout.setComponentAlignment(loginFormLayout, …
Run Code Online (Sandbox Code Playgroud)

java frameworks vaadin web

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

标签 统计

android ×1

broadcastreceiver ×1

frameworks ×1

java ×1

vaadin ×1

web ×1