Example usage for android.os PowerManager SCREEN_DIM_WAKE_LOCK

List of usage examples for android.os PowerManager SCREEN_DIM_WAKE_LOCK

Introduction

In this page you can find the example usage for android.os PowerManager SCREEN_DIM_WAKE_LOCK.

Prototype

int SCREEN_DIM_WAKE_LOCK

To view the source code for android.os PowerManager SCREEN_DIM_WAKE_LOCK.

Click Source Link

Document

Wake lock level: Ensures that the screen is on (but may be dimmed); the keyboard backlight will be allowed to go off.

Usage

From source file:im.afterclass.android.activity.ChatActivity.java

private void setUpView() {
    activityInstance = this;
    iv_emoticons_normal.setOnClickListener(this);
    iv_emoticons_checked.setOnClickListener(this);
    // position = getIntent().getIntExtra("position", -1);
    clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
    manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE))
            .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo");
    // ???/*  w w  w. j  a va2 s  . c  o m*/
    chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE);

    if (chatType == CHATTYPE_SINGLE) { // ??
        toChatUsername = getIntent().getStringExtra("userId");
        ((TextView) findViewById(R.id.name)).setText(toChatUsername);
    } else {
        // ?
        findViewById(R.id.container_to_group).setVisibility(View.VISIBLE);
        findViewById(R.id.container_remove).setVisibility(View.GONE);
        toChatUsername = getIntent().getStringExtra("groupId");
        group = EMGroupManager.getInstance().getGroup(toChatUsername);
        ((TextView) findViewById(R.id.name)).setText(group.getGroupName());
    }
    conversation = EMChatManager.getInstance().getConversation(toChatUsername);
    // ?0
    conversation.resetUnsetMsgCount();
    adapter = new MessageAdapter(this, toChatUsername, chatType);
    // ?
    listView.setAdapter(adapter);
    listView.setOnScrollListener(new ListScrollListener());
    int count = listView.getCount();
    if (count > 0) {
        listView.setSelection(count - 1);
    }

    listView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            hideKeyboard();
            more.setVisibility(View.GONE);
            iv_emoticons_normal.setVisibility(View.VISIBLE);
            iv_emoticons_checked.setVisibility(View.INVISIBLE);
            expressionContainer.setVisibility(View.GONE);
            btnContainer.setVisibility(View.GONE);
            return false;
        }
    });
    // ?
    receiver = new NewMessageBroadcastReceiver();
    IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction());
    // Mainacitivity,??chat??????
    intentFilter.setPriority(5);
    registerReceiver(receiver, intentFilter);

    // ack?BroadcastReceiver
    IntentFilter ackMessageIntentFilter = new IntentFilter(
            EMChatManager.getInstance().getAckMessageBroadcastAction());
    ackMessageIntentFilter.setPriority(5);
    registerReceiver(ackMessageReceiver, ackMessageIntentFilter);

    // show forward message if the message is not null
    String forward_msg_id = getIntent().getStringExtra("forward_msg_id");
    if (forward_msg_id != null) {
        // ?????
        forwardMessage(forward_msg_id);
    }

}

From source file:com.horizondigital.delta.UpdateService.java

@SuppressWarnings("deprecation")
@Override/*from w  ww.  j ava2s .  com*/
public void onCreate() {
    super.onCreate();

    Logger.setDebugLogging(getResources().getBoolean(R.bool.debug_output));

    property_version = getProperty(getString(R.string.property_version), "");
    property_device = getProperty(getString(R.string.property_device), "");
    filename_base = String.format(Locale.ENGLISH, getString(R.string.filename_base), property_version);
    path_base = String.format(Locale.ENGLISH, "%s%s%s%s",
            Environment.getExternalStorageDirectory().getAbsolutePath(), File.separator,
            getString(R.string.path_base), File.separator);
    path_flash_after_update = String.format(Locale.ENGLISH, "%s%s%s", path_base, "FlashAfterUpdate",
            File.separator);
    url_base_delta = String.format(Locale.ENGLISH, getString(R.string.url_base_delta), property_device);
    url_base_update = String.format(Locale.ENGLISH, getString(R.string.url_base_update), property_device);
    url_base_full = String.format(Locale.ENGLISH, getString(R.string.url_base_full), property_device);
    apply_signature = getResources().getBoolean(R.bool.apply_signature);

    Logger.d("property_version: %s", property_version);
    Logger.d("property_device: %s", property_device);
    Logger.d("filename_base: %s", filename_base);
    Logger.d("path_base: %s", path_base);
    Logger.d("path_flash_after_update: %s", path_flash_after_update);
    Logger.d("url_base_delta: %s", url_base_delta);
    Logger.d("url_base_update: %s", url_base_update);
    Logger.d("url_base_full: %s", url_base_full);

    config = Config.getInstance(this);

    wakeLock = ((PowerManager) getSystemService(POWER_SERVICE)).newWakeLock(
            config.getKeepScreenOn() ? PowerManager.SCREEN_DIM_WAKE_LOCK : PowerManager.PARTIAL_WAKE_LOCK,
            "CarbonDelta WakeLock");
    wifiLock = ((WifiManager) getSystemService(WIFI_SERVICE)).createWifiLock(WifiManager.WIFI_MODE_FULL,
            "CarbonDelta WifiLock");

    handlerThread = new HandlerThread("CarbonDelta Service Thread");
    handlerThread.start();
    handler = new Handler(handlerThread.getLooper());

    notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    prefs = PreferenceManager.getDefaultSharedPreferences(this);

    scheduler = new Scheduler(this, this);

    networkState = new NetworkState();
    networkState.start(this, this,
            prefs.getInt(PREF_AUTO_UPDATE_NETWORKS_NAME, PREF_AUTO_UPDATE_NETWORKS_DEFAULT));

    batteryState = new BatteryState();
    batteryState.start(this, this, 50, true);

    screenState = new ScreenState();
    screenState.start(this, this);

    prefs.registerOnSharedPreferenceChangeListener(this);

    autoState();
}

From source file:com.runye.express.chat.activity.ChatActivity.java

private void setUpView() {
    activityInstance = this;
    iv_emoticons_normal.setOnClickListener(this);
    iv_emoticons_checked.setOnClickListener(this);
    // position = getIntent().getIntExtra("position", -1);
    clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
    manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE))
            .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo");
    // ???/*from w  w w.  j a va2 s.com*/
    chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE);

    if (chatType == CHATTYPE_SINGLE) { // ??
        toChatUsername = getIntent().getStringExtra("userId");
        ((TextView) findViewById(R.id.name)).setText(getIntent().getStringExtra("nick"));
    } else {
        // ?
        findViewById(R.id.container_to_group).setVisibility(View.VISIBLE);
        findViewById(R.id.container_remove).setVisibility(View.GONE);
        toChatUsername = getIntent().getStringExtra("groupId");
        group = EMGroupManager.getInstance().getGroup(toChatUsername);
        ((TextView) findViewById(R.id.name)).setText(group.getGroupName());
    }
    conversation = EMChatManager.getInstance().getConversation(toChatUsername);
    // ?0
    conversation.resetUnsetMsgCount();
    adapter = new MessageAdapter(this, toChatUsername, chatType);
    // ?
    listView.setAdapter(adapter);
    listView.setOnScrollListener(new ListScrollListener());
    int count = listView.getCount();
    if (count > 0) {
        listView.setSelection(count - 1);
    }

    listView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            hideKeyboard();
            more.setVisibility(View.GONE);
            iv_emoticons_normal.setVisibility(View.VISIBLE);
            iv_emoticons_checked.setVisibility(View.INVISIBLE);
            expressionContainer.setVisibility(View.GONE);
            btnContainer.setVisibility(View.GONE);
            return false;
        }
    });
    // ?
    receiver = new NewMessageBroadcastReceiver();
    IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction());
    // Mainacitivity,??chat??????
    intentFilter.setPriority(5);
    registerReceiver(receiver, intentFilter);

    // ack?BroadcastReceiver
    IntentFilter ackMessageIntentFilter = new IntentFilter(
            EMChatManager.getInstance().getAckMessageBroadcastAction());
    ackMessageIntentFilter.setPriority(5);
    registerReceiver(ackMessageReceiver, ackMessageIntentFilter);

    // ????T
    groupListener = new GroupListener();
    EMGroupManager.getInstance().addGroupChangeListener(groupListener);

    // show forward message if the message is not null
    String forward_msg_id = getIntent().getStringExtra("forward_msg_id");
    if (forward_msg_id != null) {
        // ?????
        forwardMessage(forward_msg_id);
    }

}

From source file:com.googlecode.eyesfree.brailleback.DisplayManager.java

/**
 * Creates an instance of this class and starts the internal thread to
 * connect to the braille display service.  {@code context} is used to
 * connect to the display service.  {@code translator} is used for braille
 * translation.  The various listeners will be called as appropriate and
 * on the same thread that was used to create this object.  The current
 * thread must have a prepared looper.// w w w. j  ava2 s  . c om
 */
public DisplayManager(TranslatorManager translatorManager, Context context,
        OnPanOverflowListener panOverflowListener,
        Display.OnConnectionStateChangeListener connectionStateChangeListener,
        OnMappedInputEventListener mappedInputEventListener) {
    mTranslatorManager = translatorManager;
    mTranslatorManager.addOnTablesChangedListener(this);
    mContext = context;
    mPanOverflowListener = panOverflowListener;
    mConnectionStateChangeListener = connectionStateChangeListener;
    mMappedInputEventListener = mappedInputEventListener;
    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE,
            "BrailleBack");
    mHandlerThread = new HandlerThread("DisplayManager") {
        @Override
        public void onLooperPrepared() {
            mDisplay = new OverlayDisplay(mContext, new DisplayClient(mContext));
            mDisplay.setOnConnectionStateChangeListener(DisplayManager.this);
            mDisplay.setOnInputEventListener(DisplayManager.this);
        }
    };
    mHandlerThread.start();
    mDisplayHandler = new DisplayHandler(mHandlerThread.getLooper());
    mCallbackHandler = new CallbackHandler();
}

From source file:com.easemob.ui.ChatActivity.java

private void setUpView() {
    activityInstance = this;
    iv_emoticons_normal.setOnClickListener(this);
    iv_emoticons_checked.setOnClickListener(this);
    // position = getIntent().getIntExtra("position", -1);
    clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
    manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE))
            .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo");
    // ???/*from  ww w  .j a va2  s.  com*/
    chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE);

    if (chatType == CHATTYPE_SINGLE) { // ??
        toChatUsername = getIntent().getStringExtra("userId");
        ((TextView) findViewById(R.id.name))
                .setText(TextUtils.isEmpty(user.getRealName()) ? user.getUsername() : user.getRealName());
    } else {
        // ?
        findViewById(R.id.container_to_group).setVisibility(View.VISIBLE);
        findViewById(R.id.container_remove).setVisibility(View.GONE);
        toChatUsername = getIntent().getStringExtra("groupId");
        group = EMGroupManager.getInstance().getGroup(toChatUsername);
        ((TextView) findViewById(R.id.name)).setText(group.getGroupName());
    }
    conversation = EMChatManager.getInstance().getConversation(toChatUsername);
    // ?0
    conversation.resetUnsetMsgCount();
    adapter = new MessageAdapter(this, toChatUsername, chatType);
    // ?
    listView.setAdapter(adapter);
    listView.setOnScrollListener(new ListScrollListener());
    int count = listView.getCount();
    if (count > 0) {
        listView.setSelection(count - 1);
    }

    listView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            hideKeyboard();
            more.setVisibility(View.GONE);
            iv_emoticons_normal.setVisibility(View.VISIBLE);
            iv_emoticons_checked.setVisibility(View.INVISIBLE);
            expressionContainer.setVisibility(View.GONE);
            btnContainer.setVisibility(View.GONE);
            return false;
        }
    });
    // ?
    receiver = new NewMessageBroadcastReceiver();
    IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction());
    // Mainacitivity,??chat??????
    intentFilter.setPriority(5);
    registerReceiver(receiver, intentFilter);

    // ack?BroadcastReceiver
    IntentFilter ackMessageIntentFilter = new IntentFilter(
            EMChatManager.getInstance().getAckMessageBroadcastAction());
    ackMessageIntentFilter.setPriority(5);
    registerReceiver(ackMessageReceiver, ackMessageIntentFilter);

    // ????T
    groupListener = new GroupListener();
    EMGroupManager.getInstance().addGroupChangeListener(groupListener);

    // show forward message if the message is not null
    String forward_msg_id = getIntent().getStringExtra("forward_msg_id");
    if (forward_msg_id != null) {
        // ?????
        forwardMessage(forward_msg_id);
    }

}

From source file:com.inloc.dr.StepService.java

private void acquireWakeLock() {
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    int wakeFlags;
    if (mPedometerSettings.wakeAggressively()) {
        wakeFlags = PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP;
    } else if (mPedometerSettings.keepScreenOn()) {
        wakeFlags = PowerManager.SCREEN_DIM_WAKE_LOCK;
    } else {/*from  w w  w. j  av a2s. c om*/
        wakeFlags = PowerManager.PARTIAL_WAKE_LOCK;
    }
    wakeLock = pm.newWakeLock(wakeFlags, TAG);
    wakeLock.acquire();
}

From source file:com.google.android.apps.watchme.StreamerActivity.java

private void startStreaming() {
    Log.d(MainActivity.APP_NAME, "startStreaming");

    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, this.getClass().getName());
    wakeLock.acquire();/*from   ww  w  .j  a va 2 s . c  o m*/

    if (!streamerService.isStreaming()) {

        String cameraPermission = Manifest.permission.CAMERA;
        String microphonePermission = Manifest.permission.RECORD_AUDIO;
        int hasCamPermission = checkSelfPermission(cameraPermission);
        int hasMicPermission = checkSelfPermission(microphonePermission);
        List<String> permissions = new ArrayList<String>();
        if (hasCamPermission != PackageManager.PERMISSION_GRANTED) {
            permissions.add(cameraPermission);
            if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) {
                // Provide rationale in Snackbar to request permission
                //                    Snackbar.make(preview, R.string.permission_camera_rationale,
                //                            Snackbar.LENGTH_INDEFINITE).show();
            } else {
                // Explain in Snackbar to turn on permission in settings
                //                    Snackbar.make(preview, R.string.permission_camera_explain,
                //                            Snackbar.LENGTH_INDEFINITE).show();
            }
        }
        if (hasMicPermission != PackageManager.PERMISSION_GRANTED) {
            permissions.add(microphonePermission);
            if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.RECORD_AUDIO)) {
                // Provide rationale in Snackbar to request permission
                //                    Snackbar.make(preview, R.string.permission_microphone_rationale,
                //                            Snackbar.LENGTH_INDEFINITE).show();
            } else {
                // Explain in Snackbar to turn on permission in settings
                //                    Snackbar.make(preview, R.string.permission_microphone_explain,
                //                            Snackbar.LENGTH_INDEFINITE).show();
            }
        }
        if (!permissions.isEmpty()) {
            String[] params = permissions.toArray(new String[permissions.size()]);
            ActivityCompat.requestPermissions(this, params, REQUEST_CAMERA_MICROPHONE);
        } else {
            // We already have permission, so handle as normal
            streamerService.startStreaming(rtmpUrl);
        }
    }
}

From source file:com.interestfriend.activity.FeedBackActivity.java

private void setUpView() {
    activityInstance = this;
    iv_emoticons_normal.setOnClickListener(this);
    iv_emoticons_checked.setOnClickListener(this);
    // position = getIntent().getIntExtra("position", -1);
    clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
    manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE))
            .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo");
    // //w w w .ja  va  2s  .  c o m
    chatType = CHATTYPE_SINGLE;
    txt_title.setText("");
    conversation = EMChatManager.getInstance().getConversation(toChatUsername);
    // 0
    conversation.resetUnsetMsgCount();
    adapter = new ChatAdapter(this, toChatUsername, chatType, -1);
    // 
    listView.setAdapter(adapter);
    listView.setOnScrollListener(new ListScrollListener());
    int count = listView.getCount();
    if (count > 0) {
        listView.setSelection(count - 1);
    }

    listView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            hideKeyboard();
            more.setVisibility(View.GONE);
            iv_emoticons_normal.setVisibility(View.VISIBLE);
            iv_emoticons_checked.setVisibility(View.INVISIBLE);
            expressionContainer.setVisibility(View.GONE);
            return false;
        }
    });
    // 
    receiver = new NewMessageBroadcastReceiver();
    IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction());
    // Mainacitivity,chat
    intentFilter.setPriority(5);
    registerReceiver(receiver, intentFilter);

    // ackBroadcastReceiver
    IntentFilter ackMessageIntentFilter = new IntentFilter(
            EMChatManager.getInstance().getAckMessageBroadcastAction());
    ackMessageIntentFilter.setPriority(5);
    registerReceiver(ackMessageReceiver, ackMessageIntentFilter);

    // BroadcastReceiver
    IntentFilter deliveryAckMessageIntentFilter = new IntentFilter(
            EMChatManager.getInstance().getDeliveryAckMessageBroadcastAction());
    deliveryAckMessageIntentFilter.setPriority(5);
    registerReceiver(deliveryAckMessageReceiver, deliveryAckMessageIntentFilter);

    // show forward message if the message is not null
    String forward_msg_id = getIntent().getStringExtra("forward_msg_id");
    if (forward_msg_id != null) {
        // 
        forwardMessage(forward_msg_id);
    }

}

From source file:com.liangxun.yuejiula.huanxin.chat.activity.ChatOldActivity.java

private void setUpView() {
    activityInstance = this;
    iv_emoticons_normal.setOnClickListener(this);
    iv_emoticons_checked.setOnClickListener(this);
    // position = getIntent().getIntExtra("position", -1);
    clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
    manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE))
            .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo");
    // ??//from www  . ja  v  a  2  s. co  m
    chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE);

    if (chatType == CHATTYPE_SINGLE) { // ??
        toChatUsername = getIntent().getStringExtra("userId");
        ((TextView) findViewById(R.id.name)).setText(toChatUsername);
        // conversation =
        // EMChatManager.getInstance().getConversation(toChatUsername,false);
    } else {
        // 
        findViewById(R.id.container_to_group).setVisibility(View.VISIBLE);
        findViewById(R.id.container_remove).setVisibility(View.GONE);
        findViewById(R.id.container_voice_call).setVisibility(View.GONE);
        toChatUsername = getIntent().getStringExtra("groupId");
        group = EMGroupManager.getInstance().getGroup(toChatUsername);
        ((TextView) findViewById(R.id.name)).setText(group.getGroupName());
        // conversation =
        // EMChatManager.getInstance().getConversation(toChatUsername,true);
    }
    conversation = EMChatManager.getInstance().getConversation(toChatUsername);
    // ?0
    conversation.resetUnsetMsgCount();
    adapter = new MessageAdapter(this, toChatUsername, chatType);
    // ?
    listView.setAdapter(adapter);
    listView.setOnScrollListener(new ListScrollListener());
    int count = listView.getCount();
    if (count > 0) {
        listView.setSelection(count - 1);
    }

    listView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            hideKeyboard();
            more.setVisibility(View.GONE);
            iv_emoticons_normal.setVisibility(View.VISIBLE);
            iv_emoticons_checked.setVisibility(View.INVISIBLE);
            expressionContainer.setVisibility(View.GONE);
            btnContainer.setVisibility(View.GONE);
            return false;
        }
    });
    // ?
    receiver = new NewMessageBroadcastReceiver();
    IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction());
    // Mainacitivity,??chat??????
    intentFilter.setPriority(5);
    registerReceiver(receiver, intentFilter);

    // ack?BroadcastReceiver
    IntentFilter ackMessageIntentFilter = new IntentFilter(
            EMChatManager.getInstance().getAckMessageBroadcastAction());
    ackMessageIntentFilter.setPriority(5);
    registerReceiver(ackMessageReceiver, ackMessageIntentFilter);

    // ??BroadcastReceiver
    IntentFilter deliveryAckMessageIntentFilter = new IntentFilter(
            EMChatManager.getInstance().getDeliveryAckMessageBroadcastAction());
    deliveryAckMessageIntentFilter.setPriority(5);
    registerReceiver(deliveryAckMessageReceiver, deliveryAckMessageIntentFilter);

    // ???T
    groupListener = new GroupListener();
    EMGroupManager.getInstance().addGroupChangeListener(groupListener);

    // show forward message if the message is not null
    String forward_msg_id = getIntent().getStringExtra("forward_msg_id");
    if (forward_msg_id != null) {
        // ?????
        forwardMessage(forward_msg_id);
    }

}

From source file:com.xxjwd.chat.ChatActivity.java

    private void setUpView() {
      activityInstance = this;
      iv_emoticons_normal.setOnClickListener(this);
      iv_emoticons_checked.setOnClickListener(this);
      // position = getIntent().getIntExtra("position", -1);
      clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
      manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
      getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
      wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)).newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo");
      // ???/*from  w ww . j  ava2s  . c  o  m*/
      chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE);

      if (chatType == CHATTYPE_SINGLE) { // ??
         toChatUsername = getIntent().getStringExtra("userId");
         toChatUsername = "3974";
         ((TextView) findViewById(R.id.name)).setText(toChatUsername);
          conversation =    ChatManager.getInstance().getConversation(toChatUsername,false);
      } else {
         // ?
         findViewById(R.id.container_to_group).setVisibility(View.VISIBLE);
         findViewById(R.id.container_remove).setVisibility(View.GONE);
         findViewById(R.id.container_voice_call).setVisibility(View.GONE);
         toChatUsername = getIntent().getStringExtra("groupId");
         group = ChatGroupManager.getInstance().getGroup(toChatUsername);
         ((TextView) findViewById(R.id.name)).setText(group.getGroupName());
          conversation =
          ChatManager.getInstance().getConversation(toChatUsername,true);
      }
      conversation = ChatManager.getInstance().getConversation(toChatUsername);
      // ?0
      conversation.resetUnsetMsgCount();
      adapter = new MessageAdapter(this, toChatUsername, chatType);
      // ?
      listView.setAdapter(adapter);
      listView.setOnScrollListener(new ListScrollListener());
      int count = listView.getCount();
      if (count > 0) {
         listView.setSelection(count - 1);
      }

      listView.setOnTouchListener(new OnTouchListener() {

         @Override
         public boolean onTouch(View v, MotionEvent event) {
            hideKeyboard();
            more.setVisibility(View.GONE);
            iv_emoticons_normal.setVisibility(View.VISIBLE);
            iv_emoticons_checked.setVisibility(View.INVISIBLE);
            emojiIconContainer.setVisibility(View.GONE);
            btnContainer.setVisibility(View.GONE);
            return false;
         }
      });
//      // ?
//      receiver = new NewMessageBroadcastReceiver();
//      IntentFilter intentFilter = new IntentFilter(ChatManager.getInstance().getNewMessageBroadcastAction());
//      // Mainacitivity,??chat??????
//      intentFilter.setPriority(5);
//      registerReceiver(receiver, intentFilter);
//
//      // ack?BroadcastReceiver
//      IntentFilter ackMessageIntentFilter = new IntentFilter(ChatManager.getInstance().getAckMessageBroadcastAction());
//      ackMessageIntentFilter.setPriority(5);
//      registerReceiver(ackMessageReceiver, ackMessageIntentFilter);
//
//      // ??BroadcastReceiver
//      IntentFilter deliveryAckMessageIntentFilter = new IntentFilter(ChatManager.getInstance().getDeliveryAckMessageBroadcastAction());
//      deliveryAckMessageIntentFilter.setPriority(5);
//      registerReceiver(deliveryAckMessageReceiver, deliveryAckMessageIntentFilter);

      // ????T
      groupListener = new GroupListener();
      ChatGroupManager.getInstance().addGroupChangeListener(groupListener);

      // show forward message if the message is not null
      String forward_msg_id = getIntent().getStringExtra("forward_msg_id");
      if (forward_msg_id != null) {
         // ?????
         forwardMessage(forward_msg_id);
      }

   }