List of usage examples for android.os PowerManager SCREEN_DIM_WAKE_LOCK
int SCREEN_DIM_WAKE_LOCK
To view the source code for android.os PowerManager SCREEN_DIM_WAKE_LOCK.
Click Source Link
From source file:xj.property.activity.HXBaseActivity.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(CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(POWER_SERVICE)).newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); // ???//from w w w . jav a 2 s.co m chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); cmdCode = getIntent().getIntExtra(Config.EXPKey_CMD_CODE, 0); servantType = getIntent().getStringExtra(Config.SERVANT_TYPE);//?? ///?// ? // ? /// ? serverapp... if (TextUtils.equals(servantType, Config.SERVANT_TYPE_BANGBANG) || TextUtils.equals(servantType, Config.SERVANT_TYPE_WEIXIUTOUSU) || TextUtils.equals(servantType, Config.SERVANT_TYPE_SHOPTOUSU) || TextUtils.equals(servantType, Config.SERVANT_TYPE_WUYE)) { locationImgview.setVisibility(View.GONE); findViewById(R.id.btn_video).setVisibility(View.GONE); findViewById(R.id.tv_location).setVisibility(View.GONE); findViewById(R.id.tv_video).setVisibility(View.GONE); } cmdDetail = getIntent().getStringExtra("CMD_DETAIL"); if (chatType == CHATTYPE_SINGLE) { // ?? toChatUsername = getIntent().getStringExtra("userId"); toChatUserNick = getIntent().getStringExtra(Config.EXPKey_nickname); toChatUserAvatr = getIntent().getStringExtra(Config.EXPKey_avatar); if (toChatUserNick == null) { onError(); return; } tv_ChatName.setText(toChatUserNick); findViewById(R.id.container_remove).setVisibility(View.GONE); toChatUser = XJContactHelper.selectContact(toChatUsername); // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,false); testFrom = PreferencesUtil.getUserInfoTest(getmContext()); testTo = PreferencesUtil.getGroupUserInfoTest(getmContext(), toChatUsername); Log.d("ChatActivity: ", "testFrom " + testFrom + "testTo " + testTo); } else { // ? ????////TODO ?? XXX 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"); //get group from local group = EMGroupManager.getInstance().getGroup(toChatUsername); getGroupInfo(); if (group == null) { fetchGroupInfoFromServer(); } testFrom = PreferencesUtil.getUserInfoTest(getmContext()); groupName = group.getGroupName(); communityName = PreferencesUtil.getCommityName(getmContext()); communityId = "" + bean.getCommunityId(); Log.d("ChatActivity: ", " testFrom " + testFrom + " groupName " + groupName + " communityName " + communityName + " communityId " + communityId); //join group /* try { EMGroupManager.getInstance().joinGroup(toChatUsername); } catch (EaseMobException e) { e.printStackTrace(); }*/ // String groupName = getIntent().getStringExtra(Config.EXPKey_GROUP); // ((TextView) findViewById(R.id.name)).setText(groupName != null ? groupName : group.getGroupName()); // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,true); } conversation = EMChatManager.getInstance().getConversation(toChatUsername); // ?0 // conversation.resetUnreadMsgCount(); conversation.markAllMessagesAsRead(); Log.d("ChatActivity", "markAllMessagesAsRead is complete toChatUsername " + toChatUsername + " toChatUserNick " + toChatUserNick); // ?db?conversationgetChatOptions().getNumberOfMessagesLoaded // ??? final List<EMMessage> msgs = conversation.getAllMessages(); int msgCount = msgs != null ? msgs.size() : 0; if (msgCount < conversation.getAllMsgCount() && msgCount < pagesize) { String msgId = null; if (msgs != null && msgs.size() > 0) { msgId = msgs.get(0).getMsgId(); } if (chatType == CHATTYPE_SINGLE) { conversation.loadMoreMsgFromDB(msgId, pagesize); } else { conversation.loadMoreGroupMsgFromDB(msgId, pagesize); } } adapter = createMessageAdapter(this, toChatUsername, chatType); // ? listView.setAdapter(adapter); listView.setOnScrollListener(new ListScrollListener()); adapter.refreshSelectLast(); 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; } }); // 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); } //??sendTextWithExt?? // if (cmdCode != 0) { // logger.info("cmd detail is :" + cmdDetail); // sendTextWithExt("txt with ext", 200); // } }
From source file:uk.co.armedpineapple.cth.SDLActivity.java
protected void onResume() { super.onResume(); Log.d(LOG_TAG, "onResume()"); if (app.configuration != null && app.configuration.getKeepScreenOn()) { Log.d(LOG_TAG, "Getting wakelock"); PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); wake = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "Keep Screen On Wakelock"); wake.acquire();/*from ww w .j a va 2 s . co m*/ } if (mDrawerLayout != null) { mDrawerLayout.closeDrawers(); } }
From source file:com.wheelphone.remotemini.WheelphoneRemoteMini.java
public void onCreate(Bundle savedInstanceState) { if (debugUsbComm) { logString = TAG + ": onCreate"; Log.d(TAG, logString);//from w ww .j a va 2s . c o m appendLog("debugUsbComm.txt", logString, false); } super.onCreate(savedInstanceState); setContentView(R.layout.main); camera = (SurfaceView) findViewById(R.id.smallcameraview); context = this.getApplicationContext(); line1 = (TextView) findViewById(R.id.line1); line2 = (TextView) findViewById(R.id.line2); version = (TextView) findViewById(R.id.version); signWifi = (TextView) findViewById(R.id.advice); signStreaming = (TextView) findViewById(R.id.streaming); signInformation = (LinearLayout) findViewById(R.id.information); pulseAnimation = AnimationUtils.loadAnimation(this, R.anim.pulse); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); settings.registerOnSharedPreferenceChangeListener(this); camera.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); holder = camera.getHolder(); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "com.wheelphone.remotemini.wakelock"); httpServer = new CustomHttpServer(8080, this.getApplicationContext(), handler); soundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() { public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { soundPool.play(sampleId, 0.99f, 0.99f, 1, 0, 1); } }); timerImg = new Timer(); intent = new Intent(context, FrontImageActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //startActivity(intent); // Query the QCAR initialization flags: mQCARFlags = getInitializationFlags(); // Update the application status to start initializing application updateApplicationStatus(APPSTATUS_INIT_APP); Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); updateRendering(size.x, size.y); btnStart = (Button) findViewById(R.id.btnStart); //Make sure that the app stays open: getWindow().addFlags( WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); wheelphone = new WheelphoneRobot(getApplicationContext(), getIntent()); wheelphone.enableSpeedControl(); wheelphone.setWheelPhoneRobotListener(this); }
From source file:maimeng.yodian.app.client.android.chat.activity.ChatActivity.java
private void setUpView() { iv_emoticons_normal.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"); Map<String, RobotUser> robotMap = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getRobotList(); if (robotMap != null && robotMap.containsKey(toChatUsername)) { isRobot = true;// w w w. ja v a2s . co m } // for chatroom type, we only init conversation and create view adapter on success 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.haomee.chat.activity.ChatActivity.java
private void setUpView() { // 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"); init_from_data();/* w ww .j a v a 2 s . c o m*/ // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,false); conversation = EMChatManager.getInstance().getConversation(toChatUsername); // ?0 conversation.resetUnsetMsgCount(); adapter = new MessageAdapter(this, toChatUsername, chatType, uId); // ? 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(); hideBottom(); 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); String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } }
From source file:org.cowboycoders.cyclismo.turbo.TurboService.java
@Override public void onCreate() { super.onCreate(); trackRecordingServiceConnection = new TrackRecordingServiceConnection(this, bindChangedCallback); // trackRecordingServiceConnection.startAndBind(); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); this.gpsAccuracy = getApplicationContext().getResources().getInteger(R.integer.SIMULATED_LOCATION_ACCURACY); this.wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, TurboService.WAKE_LOCK); }
From source file:org.kde.necessitas.ministro.MinistroActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);/*from ww w . j a va2s . com*/ m_qtLibsRootPath = getFilesDir().getAbsolutePath() + "/qt/"; File dir = new File(m_qtLibsRootPath); dir.mkdirs(); nativeChmode(m_qtLibsRootPath, 0755); bindService(new Intent("org.kde.necessitas.ministro.IMinistro"), m_ministroConnection, Context.BIND_AUTO_CREATE); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); m_wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "Ministro"); m_wakeLock.acquire(); }
From source file:com.prod.intelligent7.engineautostart.ConnectDaemonService.java
private void turnScreenOn() { didNotTurnScreenOn = false;/*from w ww . ja va2 s . c om*/ WakeLockManager.acquire(this, "screenBugDim", PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, 5000); //stopSelf(); }
From source file:com.intel.xdk.device.Device.java
private void aquireWakeLock() { PowerManager pm = (PowerManager) activity.getSystemService(Context.POWER_SERVICE); wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag"); try {/*from w w w. j av a 2 s . c om*/ wl.acquire(); } catch (Exception e) { } }
From source file:org.telegram.ui.Components.ChatActivityEnterView.java
private void updateRecordIntefrace() { if (recordingAudioVideo) { if (recordInterfaceState == 1) { return; }//from w w w . j a v a2s .c om recordInterfaceState = 1; try { if (wakeLock == null) { PowerManager pm = (PowerManager) ApplicationLoader.applicationContext .getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "audio record lock"); wakeLock.acquire(); } } catch (Exception e) { FileLog.e(e); } AndroidUtilities.lockOrientation(parentActivity); recordPanel.setVisibility(VISIBLE); recordCircle.setVisibility(VISIBLE); recordCircle.setAmplitude(0); recordTimeText.setText("00:00"); recordDot.resetAlpha(); lastTimeString = null; FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) slideText.getLayoutParams(); params.leftMargin = AndroidUtilities.dp(30); slideText.setLayoutParams(params); slideText.setAlpha(1); recordPanel.setX(AndroidUtilities.displaySize.x); recordCircle.setTranslationX(0); if (runningAnimationAudio != null) { runningAnimationAudio.cancel(); } runningAnimationAudio = new AnimatorSet(); runningAnimationAudio.playTogether(ObjectAnimator.ofFloat(recordPanel, "translationX", 0), ObjectAnimator.ofFloat(recordCircle, "scale", 1), ObjectAnimator.ofFloat(audioVideoButtonContainer, "alpha", 0)); runningAnimationAudio.setDuration(300); runningAnimationAudio.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { if (runningAnimationAudio != null && runningAnimationAudio.equals(animator)) { recordPanel.setX(0); runningAnimationAudio = null; } } }); runningAnimationAudio.setInterpolator(new DecelerateInterpolator()); runningAnimationAudio.start(); } else { if (wakeLock != null) { try { wakeLock.release(); wakeLock = null; } catch (Exception e) { FileLog.e(e); } } AndroidUtilities.unlockOrientation(parentActivity); if (recordInterfaceState == 0) { return; } recordInterfaceState = 0; if (runningAnimationAudio != null) { runningAnimationAudio.cancel(); } runningAnimationAudio = new AnimatorSet(); runningAnimationAudio.playTogether( ObjectAnimator.ofFloat(recordPanel, "translationX", AndroidUtilities.displaySize.x), ObjectAnimator.ofFloat(recordCircle, "scale", 0.0f), ObjectAnimator.ofFloat(audioVideoButtonContainer, "alpha", 1.0f)); runningAnimationAudio.setDuration(300); runningAnimationAudio.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { if (runningAnimationAudio != null && runningAnimationAudio.equals(animator)) { FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) slideText.getLayoutParams(); params.leftMargin = AndroidUtilities.dp(30); slideText.setLayoutParams(params); slideText.setAlpha(1); recordPanel.setVisibility(GONE); recordCircle.setVisibility(GONE); runningAnimationAudio = null; } } }); runningAnimationAudio.setInterpolator(new AccelerateInterpolator()); runningAnimationAudio.start(); } }