List of usage examples for android.content Context POWER_SERVICE
String POWER_SERVICE
To view the source code for android.content Context POWER_SERVICE.
Click Source Link
From source file:com.erhuoapp.erhuo.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 www . j a v a 2 s . c om*/ chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); // ???? HeadAndName mHeadAndName = new HeadAndName(this); UserHeadAndName mUserHeadAndName = mHeadAndName.selectOne(toChatUsername); ((TextView) findViewById(R.id.name)).setText(mUserHeadAndName.getNick()); // 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); findViewById(R.id.container_video_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.resetUnreadMsgCount(); 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(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.devalladolid.musictoday.MusicService.java
@Override public void onCreate() { if (D)//from w w w .jav a 2 s . c o m Log.d(TAG, "Creating service"); super.onCreate(); mNotificationManager = NotificationManagerCompat.from(this); // gets a pointer to the playback state store mPlaybackStateStore = MusicPlaybackState.getInstance(this); mSongPlayCount = SongPlayCount.getInstance(this); mRecentStore = RecentStore.getInstance(this); mHandlerThread = new HandlerThread("MusicPlayerHandler", android.os.Process.THREAD_PRIORITY_BACKGROUND); mHandlerThread.start(); mPlayerHandler = new MusicPlayerHandler(this, mHandlerThread.getLooper()); mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); mMediaButtonReceiverComponent = new ComponentName(getPackageName(), MediaButtonIntentReceiver.class.getName()); mAudioManager.registerMediaButtonEventReceiver(mMediaButtonReceiverComponent); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) setUpMediaSession(); mPreferences = getSharedPreferences("Service", 0); mCardId = getCardId(); registerExternalStorageListener(); mPlayer = new MultiPlayer(this); mPlayer.setHandler(mPlayerHandler); // Initialize the intent filter and each action final IntentFilter filter = new IntentFilter(); filter.addAction(SERVICECMD); filter.addAction(TOGGLEPAUSE_ACTION); filter.addAction(PAUSE_ACTION); filter.addAction(STOP_ACTION); filter.addAction(NEXT_ACTION); filter.addAction(PREVIOUS_ACTION); filter.addAction(PREVIOUS_FORCE_ACTION); filter.addAction(REPEAT_ACTION); filter.addAction(SHUFFLE_ACTION); // Attach the broadcast listener registerReceiver(mIntentReceiver, filter); mMediaStoreObserver = new MediaStoreObserver(mPlayerHandler); getContentResolver().registerContentObserver(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, true, mMediaStoreObserver); getContentResolver().registerContentObserver(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, true, mMediaStoreObserver); // Initialize the wake lock final PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName()); mWakeLock.setReferenceCounted(false); final Intent shutdownIntent = new Intent(this, MusicService.class); shutdownIntent.setAction(SHUTDOWN); mAlarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); mShutdownIntent = PendingIntent.getService(this, 0, shutdownIntent, 0); scheduleDelayedShutdown(); reloadQueueAfterPermissionCheck(); notifyChange(QUEUE_CHANGED); notifyChange(META_CHANGED); }
From source file:org.runnerup.gpstracker.GpsTracker.java
private void wakelock(boolean get) { if (mWakeLock != null) { if (mWakeLock.isHeld()) { mWakeLock.release();/* ww w .j av a 2s . com*/ } mWakeLock = null; } if (get) { PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "RunnerUp"); if (mWakeLock != null) { mWakeLock.acquire(); } } }
From source file:com.interestfriend.activity.ChatActivity.java
private void setUpView() { activityInstance = this; iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); btnMore.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. c o m*/ chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); txt_title.setText(user_name); conversation = EMChatManager.getInstance().getConversation(toChatUsername); // 0 conversation.resetUnsetMsgCount(); adapter = new ChatAdapter(this, toChatUsername, chatType, user_id); // 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); // 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); // 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.max2idea.android.limbo.main.LimboActivity.java
private void acquireLocks() { if (mWakeLock == null) { PowerManager pm = (PowerManager) activity.getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, WAKELOCK_KEY); mWakeLock.setReferenceCounted(false); }/*w ww.j ava 2 s . co m*/ // Creates a new WifiLock by getting the WifiManager as a service. // This object creates a lock tagged "lock". if (wlock == null) { WifiManager wmanager = (WifiManager) activity.getSystemService(Context.WIFI_SERVICE); wlock = wmanager.createWifiLock("lock"); wlock.setReferenceCounted(false); } if (!mWakeLock.isHeld()) { Log.v(TAG, "Acquire wake lock..."); mWakeLock.acquire(); } if (!wlock.isHeld()) { Log.v(TAG, "Acquire wifi lock..."); wlock.acquire(); } }
From source file:com.nogago.android.tracks.services.TrackRecordingService.java
/** * Tries to acquire a partial wake lock if not already acquired. Logs errors * and gives up trying in case the wake lock cannot be acquired. *//*w w w . j a v a 2 s . c o m*/ private void acquireWakeLock() { try { PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); if (pm == null) { Log.e(TAG, "TrackRecordingService: Power manager not found!"); return; } if (wakeLock == null) { wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG); if (wakeLock == null) { Log.e(TAG, "TrackRecordingService: Could not create wake lock (null)."); return; } } if (!wakeLock.isHeld()) { wakeLock.acquire(); if (!wakeLock.isHeld()) { Log.e(TAG, "TrackRecordingService: Could not acquire wake lock."); } } } catch (RuntimeException e) { Log.e(TAG, "TrackRecordingService: Caught unexpected exception: " + e.getMessage(), e); } }
From source file:com.hanyu.desheng.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 www .j a v a2s. c om*/ chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); String username = getIntent().getStringExtra("username"); if (username != null) { if (username.length() < 7) { ((TextView) findViewById(R.id.name)).setText(username); } else { ((TextView) findViewById(R.id.name)).setText(username.substring(0, 7) + "..."); } } else { Gson gson = new Gson(); List<String> userList = new ArrayList<String>(); userList.add(toChatUsername); final String uns = gson.toJson(userList); new HttpTask<Void, Void, String>(ChatActivity.this) { // private AlertDialog errorDialog; @Override protected String doInBackground(Void... params) { return EngineManager.getUserEngine().toGetHxUser(uns); } @Override protected void onPostExecute(String result) { if (result != null) { LogUtils.e(getClass(), "result:" + result); ChatBean chatBean = GsonUtils.json2Bean(result, ChatBean.class); if (chatBean != null && chatBean.code == 0) { String username = chatBean.data.info_list.get(0).miname; if (username.length() < 7) { ((TextView) findViewById(R.id.name)).setText(username); } else { ((TextView) findViewById(R.id.name)).setText(username.substring(0, 7) + "..."); } } else { } } } @Override protected void onPreExecute() { } }.executeProxy(); } // 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); findViewById(R.id.container_video_call).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("groupId"); ISCANCHAT = GroupDao.getGroup(toChatUsername, ExampleApplication.getInstance().getUserName()); if (!ISCANCHAT) { CountDown cd = new CountDown(5000, 1000); cd.start(); } group = EMGroupManager.getInstance().getGroup(toChatUsername); new Thread() { public void run() { try { String checkUserChat = EngineManager.getUserEngine().checkUserChat( ExampleApplication.getInstance().getUserName(), getIntent().getStringExtra("groupId")); JSONObject jsonObject = new JSONObject(checkUserChat); JSONObject jsonObject2 = jsonObject.getJSONObject("data"); String isSilence = jsonObject2.getString("is_silence"); if (isSilence.equals("1")) { runOnUiThread(new Runnable() { @Override public void run() { // ? mEditTextContent.setHint("?"); mEditTextContent.setEnabled(false); buttonPressToSpeak.setEnabled(false); } }); } } catch (Exception e) { e.printStackTrace(); } }; }.start(); // ? registerBandListener(); if (group != null) { if (group.getGroupName().length() < 7) { ((TextView) findViewById(R.id.name)) .setText(group.getGroupName() + "(" + group.getAffiliationsCount() + ")"); } else { ((TextView) findViewById(R.id.name)).setText( group.getGroupName().substring(0, 7) + "...(" + group.getAffiliationsCount() + ")"); } } else ((TextView) findViewById(R.id.name)).setText(toChatUsername); // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,true); } conversation = EMChatManager.getInstance().getConversation(toChatUsername); // ?0 conversation.resetUnreadMsgCount(); 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; } }); //EMChatManager.getInstance().getChatOptions().setShowNotificationInBackgroud(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:br.com.viniciuscr.notification2android.mediaPlayer.MediaPlaybackService.java
@Override public void onCreate() { super.onCreate(); mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); ComponentName rec = new ComponentName(getPackageName(), MediaButtonIntentReceiver.class.getName()); mAudioManager.registerMediaButtonEventReceiver(rec); Intent i = new Intent(Intent.ACTION_MEDIA_BUTTON); i.setComponent(rec);//from www.j a v a2 s .c o m PendingIntent pi = PendingIntent.getBroadcast(this /*context*/, 0 /*requestCode, ignored*/, i /*intent*/, 0 /*flags*/); mRemoteControlClient = new RemoteControlClient(pi); mAudioManager.registerRemoteControlClient(mRemoteControlClient); int flags = RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS | RemoteControlClient.FLAG_KEY_MEDIA_NEXT | RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_STOP; mRemoteControlClient.setTransportControlFlags(flags); mPreferences = getSharedPreferences("Music", MODE_WORLD_READABLE | MODE_WORLD_WRITEABLE); mCardId = MusicUtils.getCardId(this); registerExternalStorageListener(); // Needs to be done in this thread, since otherwise ApplicationContext.getPowerManager() crashes. mPlayer = new MultiPlayer(); mPlayer.setHandler(mMediaplayerHandler); reloadQueue(); notifyChange(QUEUE_CHANGED); notifyChange(META_CHANGED); IntentFilter commandFilter = new IntentFilter(); commandFilter.addAction(SERVICECMD); commandFilter.addAction(TOGGLEPAUSE_ACTION); commandFilter.addAction(PAUSE_ACTION); commandFilter.addAction(NEXT_ACTION); commandFilter.addAction(PREVIOUS_ACTION); registerReceiver(mIntentReceiver, commandFilter); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, this.getClass().getName()); mWakeLock.setReferenceCounted(false); // If the service was idle, but got killed before it stopped itself, the // system will relaunch it. Make sure it gets stopped again in that case. Message msg = mDelayedStopHandler.obtainMessage(); mDelayedStopHandler.sendMessageDelayed(msg, IDLE_DELAY); }
From source file:com.youti.chat.activity.ChatActivity.java
private void setUpView() { 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"); ((TextView) findViewById(R.id.name)).setText(toChatUserName); /*if (chatType == CHATTYPE_SINGLE) { // ?? /*from ww w.j a va 2 s . com*/ } 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); findViewById(R.id.container_video_call).setVisibility(View.GONE); toTel = getIntent().getStringExtra("groupId"); if(chatType == CHATTYPE_GROUP){ onGroupViewCreation(); }else{ onChatRoomViewCreation(); } }*/ // for chatroom type, we only init conversation and create view adapter on success if (chatType != CHATTYPE_CHATROOM) { onConversationInit(); onListViewCreation(); // 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.fullteem.yueba.app.ui.ChatActivity.java
private void setUpView() { // popwindow//from www.j a va 2s.c o m menuTexts = getResources().getStringArray(R.array.msgmenu); 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"); // ??? chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? // ?? Map<String, User> users = appContext.getContactList(); toChatUsername = getIntent().getStringExtra("userId");// bug bill.// should be// imServerId if (null == toChatUsername) { return; } userNickName = getIntent().getStringExtra("nickname"); getUserTokenByAccount(toChatUsername); ImageUrl = getIntent().getStringExtra("imgurl"); List<String> blackList = EMContactManager.getInstance().getBlackListUsernames(); for (String key : users.keySet()) { // ?????? if (null != toChatUsername && toChatUsername.equalsIgnoreCase(key)// debug to be // null! && !blackList.contains(key)) { menuTexts = getResources().getStringArray(R.array.msgmenu_friend); } } ((TextView) findViewById(R.id.name)).setText(userNickName); // 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"); System.out.println("toChatUsername" + toChatUsername); group = EMGroupManager.getInstance().getGroup(toChatUsername); menuTexts = getResources().getStringArray(R.array.msgmenu_group); if (group == null) { ((TextView) findViewById(R.id.name)).setText(""); } else { ((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, ImageUrl, 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(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); } }