首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

一些API的运用

2012-08-29 
一些API的使用?Paint paint new Paint()// setColor 须在 setAlpha 方法之前设置,原因请参见 Android A

一些API的使用

?  Paint paint = new Paint();  // setColor 须在 setAlpha 方法之前设置,原因请参见 Android API  paint.setColor(Color.GRAY);  // 值越大越不透明  paint.setAlpha(255);

?

//取得屏幕分辨率DisplayMetrics dm = new DisplayMetrics();   getWindowManager().getDefaultDisplay().getMetrics(dm);   

?

?

// 去掉标题栏requestWindowFeature(Window.FEATURE_NO_TITLE);

?

// 设置为全屏getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,   WindowManager.LayoutParams.FLAG_FULLSCREEN);  

?

// 如何一个 service 被调用很多次,即 onStartCommand() 响应过很多个请求,// 那么会相应的产生很多个 startId,比如:1,2,3 三个// 那么,stopSelfResult(int startId) 只会在参数为 3 的时候才会真正地停止这个服务// 另外,stopSelf() 是stopSelfResult()的老版本,推荐使用新版本boolean result = stopSelfResult(msg.arg1);

?

/**     * Show a notification while this service is running.     */    private void showNotification() {        // In this sample, we'll use the same text for the ticker and the expanded notification        CharSequence text = getText(R.string.local_service_started);        // Set the icon, scrolling text and timestamp        Notification notification = new Notification(R.drawable.stat_sample, text,                System.currentTimeMillis());        // The PendingIntent to launch our activity if the user selects this notification        PendingIntent contentIntent = PendingIntent.getActivity(this, 0,                new Intent(this, LocalServiceActivities.Controller.class), 0);        // Set the info for the views that show in the notification panel.        notification.setLatestEventInfo(this, getText(R.string.local_service_label),                       text, contentIntent);        // Send the notification.        // We use a layout id because it is a unique number.  We use it later to cancel.        mNM.notify(R.string.local_service_started, notification);    }

?

热点排行