当前位置:  编程技术>移动开发
本页文章导读:
    ▪依据系统时间设置现在格式化日期时间        根据系统时间设置现在格式化日期时间 Calendar mDummyDate; mDummyDate = Calendar.getInstance();        java.text.DateFormat shortDateFormat = DateFormat.getDateFormat(context);//注意这个要导入 import android.text.forma.........
    ▪ 小弟我的一些代码        我的一些代码 public class TestNotifycationActivity extends Activity { private NotificationManager mNotificationManager; public static final int NOTIFICATION_ID=11;    /** Called when the activity is first created. */    @Override   .........
    ▪ 三星已经禁止运行在其余手机上的S Voice应用访问服务器了       三星已经禁止运行在其他手机上的S Voice应用访问服务器了 S Voice刚被破解不久,三星就采取行动,禁止运行在其他手机上的S Voice应用访问服务器。还没试过的玩家目前没机会试用S Voice了。 ......

[1]依据系统时间设置现在格式化日期时间
    来源: 互联网  发布时间: 2014-02-18
根据系统时间设置现在格式化日期时间
Calendar mDummyDate;
mDummyDate = Calendar.getInstance();
        java.text.DateFormat shortDateFormat = DateFormat.getDateFormat(context);//注意这个要导入 import android.text.format.DateFormat;  这个包而不是 java下的包,倒错会报错的
        final Calendar now = Calendar.getInstance();
        mDummyDate.setTimeZone(now.getTimeZone());
        mDummyDate.set(now.get(Calendar.YEAR), 11, 31, 13, 0, 0);
        Date dummyDate = mDummyDate.getTime();
        Log.i(TAG, "date format: " + shortDateFormat.format(dummyDate));
       // if (format != null && !format.equals("")) {
            SimpleDateFormat formatter = new SimpleDateFormat(shortDateFormat.format(date));
            String mTimestampd = formatter.format(date);
            String time = MessageUtils.formatDateStampString(context, date);
            String showtime = mTimestampd + " " + time;
            mTimestampHW = showtime;
            Log.i(TAG, " mTimestampHW = "+mTimestampHW);
            System.out.println(" date = " + date + " date+ mTimestamp = showtime==" + showtime + "  mTimestampHW  =  " + mTimestampHW);
       // } else {
           
        //    mTimestampHW = MessageUtils.formatDateStampString(context, date, true);
            Log.i(TAG, " mTimestampHW = "+mTimestampHW);
//=====================================================================
//格式化时间 
public static String formatDateStampString(Context context, long when) {
        Time then = new Time();
        then.set(when);
        Time now = new Time();
        now.setToNow();
        // Basic settings for formatDateTime() we want for all cases.
        int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT |
                           DateUtils.FORMAT_ABBREV_ALL |
                           DateUtils.FORMAT_CAP_AMPM;
            format_flags |= DateUtils.FORMAT_SHOW_TIME;;
        return DateUtils.formatDateTime(context, when, format_flags);
    }
//格式化日期和时间
    public static String formatTimeStampString(Context context, long when, boolean fullFormat) {
        Time then = new Time();
        then.set(when);
        Time now = new Time();
        now.setToNow();

        // Basic settings for formatDateTime() we want for all cases.
        int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT |
                           DateUtils.FORMAT_ABBREV_ALL |
                           DateUtils.FORMAT_CAP_AMPM;

        // If the message is from a different year, show the date and year.
        if (then.year != now.year) {
            format_flags |= DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE;
        } else if (then.yearDay != now.yearDay) {
            // If it is from a different day than today, show only the date.
            format_flags |= DateUtils.FORMAT_SHOW_DATE;
        } else {
            // Otherwise, if the message is from today, show the time.
            format_flags |= DateUtils.FORMAT_SHOW_TIME;
        }

        // If the caller has asked for full details, make sure to show the date
        // and time no matter what we've determined above (but still make showing
        // the year only happen if it is a different year from today).
        if (fullFormat) {
            format_flags |= (DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME);
           
           
        }

        return DateUtils.formatDateTime(context, when, format_flags);}
 

    
[2] 小弟我的一些代码
    来源: 互联网  发布时间: 2014-02-18
我的一些代码
public class TestNotifycationActivity extends Activity {
private NotificationManager mNotificationManager;
public static final int NOTIFICATION_ID=11;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        sendNotification(this);
        IntentFilter myfi = new IntentFilter("wangqianwangqian");
        this.registerReceiver(new MyBroad(), myfi);
    }
   
    public  void sendNotification(Context con){
    mNotificationManager = (NotificationManager) con.getSystemService(NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.my, "All Backup",System.currentTimeMillis());
//notification.flags = Notification.FLAG_ONGOING_EVENT;
//notification.defaults =Notification.DEFAULT_SOUND;
//notification.defaults =Notification.DEFAULT_ALL;
notification.flags = Notification.FLAG_AUTO_CANCEL;
Intent intent;
intent= new Intent();
intent.setAction("wangqianwangqian");
//intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent contentIntent = PendingIntent.getActivity(con, 0,intent,PendingIntent.FLAG_CANCEL_CURRENT);
RemoteViews views = new RemoteViews(con.getPackageName(), R.layout.notify);
PendingIntent contentIntent1 = PendingIntent.getBroadcast(con, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
views.setOnClickPendingIntent(R.id.myClear, contentIntent1);
notification.contentView = views;
//notification.contentView = contentView;
//notification.contentIntent = contentIntent;
//notification.setLatestEventInfo(con, "ArchermindMusic", musicName, contentIntent);
        mNotificationManager.notify(NOTIFICATION_ID, notification);
    }
   
    public class MyBroad extends BroadcastReceiver{
    @Override
    public void onReceive(Context context, Intent intent) {
    if(intent.getAction().equals("wangqianwangqian")){
    mNotificationManager.cancel(NOTIFICATION_ID);
    }
   
    }
    }



public static boolean isNetWork(Context context){
ConnectivityManager manager =(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
if(manager!=null){
NetworkInfo info = manager.getActiveNetworkInfo();
if(info!=null && info.isConnected()){
if(info.getState() == NetworkInfo.State.CONNECTED){
return true;
}
}
}
return false;

}

    
[3] 三星已经禁止运行在其余手机上的S Voice应用访问服务器了
    来源: 互联网  发布时间: 2014-02-18
三星已经禁止运行在其他手机上的S Voice应用访问服务器了

S Voice刚被破解不久,三星就采取行动,禁止运行在其他手机上的S Voice应用访问服务器。还没试过的玩家目前没机会试用S Voice了。


    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3