当前位置: 编程技术>移动开发
本页文章导读:
▪圆桌面快捷方式 桌面快捷方式
自己做了一个简单的邮件发送示例,手机可以正常发送
其中Intent.EXTRA_SHORTCUT_NAME对应快捷方式的名字;
Intent.EXTRA_SHORTCUT_ICON_RESOURCE对应快捷方式执行的图标;
Intent.EXTRA_SHORTCUT_INTE.........
▪ 新建文件夹——模拟电话薄,拨通电话 新建文件夹——模拟电话薄,拨打电话
桌面文件夹——电话薄的小案例:
public class FoldersActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// .........
▪ date 依据当前时间获得昨天的日期 date 根据当前时间获得昨天的日期
Date now = new Date(); Date yesterday = new Date();yesterday.setTime(now.getTime()-24*60*60*1000);//当前时间减去一天的时间DateFormat df = new SimpleDateFormat("yyyy-MM-dd");System.out.println.........
[1]圆桌面快捷方式
来源: 互联网 发布时间: 2014-02-18
桌面快捷方式
自己做了一个简单的邮件发送示例,手机可以正常发送
其中Intent.EXTRA_SHORTCUT_NAME对应快捷方式的名字;
Intent.EXTRA_SHORTCUT_ICON_RESOURCE对应快捷方式执行的图标;
Intent.EXTRA_SHORTCUT_INTENT对应快捷方式的事件
android专门提供了Intent.ShortcutResource.fromcontent来创建快捷方式的图标,
最后通过setREsult来返回,构建一个快捷方式
public class ShortCutsActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 要添加的快捷方式的Intent
Intent addShortcut;
if (getIntent().getAction().equals(Intent.ACTION_CREATE_SHORTCUT)) {
addShortcut = new Intent();
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, "发送邮件");
// 构建快捷方式中专门的图标
Parcelable icon = Intent.ShortcutIconResource.fromContext(this,
R.drawable.ic_launcher);
// 添加快捷方式图标
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
// 构建快捷方式执行的Intent
Intent mailto = new Intent(Intent.ACTION_SENDTO, Uri
.parse("mailto:591449193@qq.com"));
// 添加快捷方式Intent
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, mailto);
// 正常
setResult(RESULT_OK, addShortcut);
} else {
// 取消
setResult(RESULT_CANCELED);
}
finish();
}
}
然后在mainfest.xml中引用
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".ShortCutsActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.CREATE_SHORTCUT" />
</intent-filter>
</activity>
</application>
[2] 新建文件夹——模拟电话薄,拨通电话
来源: 互联网 发布时间: 2014-02-18
新建文件夹——模拟电话薄,拨打电话
桌面文件夹——电话薄的小案例:
public class FoldersActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.main);
// 判断是否创建实时文件夹
if (getIntent().getAction().equals(
LiveFolders.ACTION_CREATE_LIVE_FOLDER)) {
Intent intent = new Intent();
intent.setData(Uri.parse("content://contacts/live_folders/people"));
// 设置单击之后的事件,这里单击一个联系人之后,呼叫;
intent
.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_BASE_INTENT,
new Intent(Intent.ACTION_CALL,
Contacts.People.CONTENT_URI));
// 设置实时文件夹的名字
intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_NAME, "电话薄");
// 设置实时文件夹的图标
intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_ICON,
Intent.ShortcutIconResource.fromContext(this,
R.drawable.folder));
// 设置显示模式为列表
intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_DISPLAY_MODE,
LiveFolders.DISPLAY_MODE_LIST);
// 完成
setResult(RESULT_OK, intent);
} else {
setResult(RESULT_CANCELED);
}
finish();
}
}
然后在mainfest.xml中注册是添加action动作
<application
android:icon="@drawable/folder"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".FoldersActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.CREATE_LIVE_FOLDER" />
<action android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
[3] date 依据当前时间获得昨天的日期
来源: 互联网 发布时间: 2014-02-18
date 根据当前时间获得昨天的日期
Date now = new Date();
Date yesterday = new Date();
yesterday.setTime(now.getTime()-24*60*60*1000);//当前时间减去一天的时间
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
System.out.println("昨天:"+df.format(yesterday));
Date now = new Date();
Date yesterday = new Date();
yesterday.setTime(now.getTime()-24*60*60*1000);//当前时间减去一天的时间
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
System.out.println("昨天:"+df.format(yesterday));
最新技术文章: