当前位置:   article > 正文

每天进步一点_import gradle project,this will also enable gradle

import gradle project,this will also enable gradle tool window
1.android studio设置方法注解对应eclipse的shift+alt+j

这个需要自己添加快捷键,对应的是fix doc comment,方法是Ctrl+Alt+S打开设置,找到keymap,找到fix doc comment自己添加快捷键,我设置的为Ctrl+Alt+D(doc的意思)






2.

========关于从Git 上下载项目无法编译的问题========

如果你从Git上下载了项目之后,发现整个文件是空的,并且在Android Studio中看到了如下信息: Unlinked Gradle project? Import Gradle project, this will also enable Gradle Tool Window. Don't want to see the message for the project again: press here. 请点击Import Gradle project,然后选择主目录即AndroidApp下的build.gradle 文件进行编译。


3.数据库升级




4.绘制虚线

  1. <shape xmlns:android="http://schemas.android.com/apk/res/android"
  2. android:shape="line">
  3. <stroke android:width="@dimen/dimen_1_dip" android:color="#000000"
  4. android:dashWidth="@dimen/dimen_10_dip" android:dashGap="@dimen/dimen_10_dip" />
  5. </shape>


在layout中,给View设置background,在预览的时候,虚线正常显示。
但是安装到手机中,显示的却是实线。huawei 3c和小米都是这样。


使用hardwareAccelerate引起的渲染错误...

(1). 把这个Activity的硬件加速关了...
manifest里 
<activity
..............
android:hardwareAccelerated="false" />

(2). 或者从View层级上把硬件加速关掉  view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);



4.需求是这样的,在服务中启动一个dialog类型的activityB

需要在该activity下设置taskAffinity,这样就不会在同一个task中显示了,在任务栏中就会显示之前的activity和现在这个activityB

然后在设置这句,就可以使ActivityB不在最近任务中显示

android:excludeFromRecents="true"

  1. <activity
  2. android:taskAffinity="com.example.test"
  3. android:name=".ChatActivity"
  4. android:configChanges="keyboardHidden|orientation"
  5. android:launchMode="singleInstance"
  6. android:excludeFromRecents="true"
  7. android:screenOrientation="portrait"
  8. android:theme="@style/Theme.HalfTranslucent"
  9. android:windowSoftInputMode="stateAlwaysHidden|adjustResize"
  10. >
  11. </activity>

  1. Intent mIntent = new Intent();
  2. mIntent.setClass(MainActivity.this, ChatActivity.class);
  3. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_NO_HISTORY);
  4. startActivity(mIntent);


5.Android ormlite使用事务

批量操作肯定是要添加事务的,这里有两种添加事务的方法。
一种是

     
     
1
2
3
4
5
6
7
8
9
10
11
12
     
     
TransactionManager.callInTransaction(DatabaseManager.getHelper()
.getConnectionSource(), new Callable<Void>() {
@Override
public Void call() throws Exception {
// TODO Auto-generated method stub
数据操作
return null;
}
});

另一种是:

     
     
1
2
3
4
5
6
7
8
9
     
     
savepoint = connection.setSavePoint(POINTNAME);
time = System.currentTimeMillis();
for (Category cate : cateList) {
cateRuntimeDao.create(cate);
}
for (Item item : itemList) {
itemRuntimeDao.create(item);
}
connection.commit(savepoint);

但是第二中没有试验成功


6.简单播放安卓系统的提示音

  1. Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);  
  2.                     Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);  
  3.                     r.play(); 

7.判断一个应用是否从后台启动的,并且是重新传了intent

参考:http://www.cnblogs.com/coding-way/archive/2013/06/05/3118732.html

http://blog.csdn.net/zzp16/article/details/7956768

这个是后台图标点击的事件处理

private void switchTo(RecentTag tag) {
        if (tag.info.id >= 0) {
            // 这个Task没有退出,直接移动到前台
            final ActivityManager am = (ActivityManager)
                    getContext().getSystemService(Context.ACTIVITY_SERVICE);
            am.moveTaskToFront(tag.info.id, ActivityManager.MOVE_TASK_WITH_HOME);
        } else if (tag.intent != null) {
            //task退出了的话,id为-1,则使用RecentTag中的Intent重新启动
            tag.intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
                    | Intent.FLAG_ACTIVITY_TASK_ON_HOME);
            try {
                getContext().startActivity(tag.intent);
            } catch (ActivityNotFoundException e) {
                Log.w("Recent", "Unable to launch recent task", e);
            }
        }
    }

判断是否从那里启动

if ((intent.getFlags()&Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY)!=0) {
finish();
}




声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/277624?site
推荐阅读
相关标签
  

闽ICP备14008679号