js简化判断是否为手机访问
1 | var ua = navigator.userAgent; |
1 | var ua = navigator.userAgent; |
1 | ng-init="outerIndex = $index;" |
1 | <div class="category-nav"> |
1 | $scope.clickNavSecondCategory = function (outerIndex,innerIndex) { |
一般的窗口关闭的JS如下写法:
1 | window.close() |
但是呢,chrome,firefox等中有时候会不起作用。改为下面的写法:
1 | window.open("about:blank","_self").close() |
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.
1 | $ hexo new "My New Post" |
More info: Writing
1 | $ hexo server |
More info: Server
1 | $ hexo generate |
More info: Generating
1 | $ hexo deploy |
More info: Deployment
1 | display: -webkit-box; |
CSS常用div阴影效果
1 | box-shadow: 0 1px 5px 0 rgba(0,0,0,.5); |
CSS常用文字阴影效果
1 | text-shadow: 0 0 0.1em #666, 0 0 0.3em #666,0 0 0.1em #666 |
Safari消除CSS点击A出现短暂半透明效果
1 | a,img { |
1 | -webkit-touch-callout: none; |
1 | 在css中推荐使用中文字体的英文表示法,以下附常见中文字体的英文名: |
1 | &_ul { |
项目近期开发加入百度地图的需求,初次使用遇到一些基础问题,总结如下:
百度地图的KEY申请地址http://lbsyun.baidu.com/,基础使用直接看百度地图API就可以,有Demo。
百度地图显示的时候全是网格没有地图,基本肯定就是KEY的问题。
1 | BaiduMapOptions compassEnabled(boolean enabled)//设置是否允许指南针,默认允许。 |
1 | MapView mMapView = (MapView)findViewById(R.id.mapview); |
1 | //地图级别3-2000km |
1 | ** |
1 | BitmapDescriptor bitmap = BitmapDescriptorFactory |
通常地图会显示出多个点,如像行驶轨迹等,往往在屏幕上一次性就全部显示出来,那要怎么设置地图的显示宽高,才能将所有的点合理的显示出来呢。看看以下的代码实现:
1 | private void setMyLocation() { |
以下为工具类BaiduMapUtil的具体实现
1 | public class BaiduMapUtil { |
1 | if (isFrist) { |
1 | ActionBar actionBar=getSupportActionBar(); |
####解决方法:
1 |
|
public void useForeground(CharSequence tickerText, String currSong) {
Intent notificationIntent = new Intent(getApplicationContext(), MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, 0);
/* Method 01
* this method must SET SMALLICON!
* otherwise it can't do what we want in Android 4.4 KitKat,
* it can only show the application info page which contains the 'Force Close' button.*/
NotificationCompat.Builder mNotifyBuilder = new NotificationCompat.Builder(PlayService.this)
.setSmallIcon(R.drawable.ic_launcher)
.setTicker(tickerText)
.setWhen(System.currentTimeMillis())
.setContentTitle(getString(R.string.app_name))
.setContentText(currSong)
.setContentIntent(pendingIntent);
Notification notification = mNotifyBuilder.build();
/* Method 02
Notification notification = new Notification(R.drawable.ic_launcher, tickerText,
System.currentTimeMillis());
notification.setLatestEventInfo(PlayService.this, getText(R.string.app_name),
currSong, pendingIntent);
*/
startForeground(NOTIFY_ID, notification);
}1
2
3
4
5
6
7
8
9## android黑屏后保持Service运行
```java
private PowerManager.WakeLock wakeLock = null;
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, MyService.class.getName());
wakeLock.acquire();
//需要权限
<uses-permission android:name="android.permission.WAKE_LOCK" />