当前位置:  编程技术>移动开发
本页文章导读:
    ▪alertUIAlertView下添加UIActivityIndicatorView, 自动消失AlertView        alertUIAlertView上添加UIActivityIndicatorView, 自动消失AlertView   uploadAlertView= [[UIAlertView alloc] initWithTitle:@"上报中" message:@"请稍等.." delegate:self cancelButtonTitle:nil otherButtonTitles:nil, nil]; UI.........
    ▪ appwidget展示当前的位置        appwidget显示当前的位置 先看下效果吧!MyAppWidgetProvider .javapublic class MyAppWidgetProvider extends AppWidgetProvider{  private Timer timer;  private int[] appWidgetIds;  private AppWidgetManager appWidgetManager;  private Cont.........
    ▪ objective-c md5事例       objective-c md5例子 转自:http://www.cnblogs.com/tracy-e/archive/2011/04/13/1877351.html     @interface NSString (MyExtensions) - (NSString *) md5; @end   @implementation NSString (MyExtensions) - (NSString *) md5 {     const char *cStr = [sel.........

[1]alertUIAlertView下添加UIActivityIndicatorView, 自动消失AlertView
    来源: 互联网  发布时间: 2014-02-18
alertUIAlertView上添加UIActivityIndicatorView, 自动消失AlertView



 
uploadAlertView= [[UIAlertView alloc] initWithTitle:@"上报中" message:@"请稍等.." 
												   delegate:self cancelButtonTitle:nil otherButtonTitles:nil, nil];
	
UIActivityIndicatorView* activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
activityView.frame = CGRectMake(139.0f-18.0f, 80.0f, 27.0f, 27.0f);
[uploadAlertView addSubview:activityView];
[activityView startAnimating];
[activityView release];
[uploadAlertView show];
 
自动消失代码:
[uploadAlertView dismissWithClickedButtonIndex:0 animated:YES];
 


    
[2] appwidget展示当前的位置
    来源: 互联网  发布时间: 2014-02-18
appwidget显示当前的位置
先看下效果吧!



MyAppWidgetProvider .java

public class MyAppWidgetProvider extends AppWidgetProvider{
  private Timer timer;
  private int[] appWidgetIds;
  private AppWidgetManager appWidgetManager;
  private Context context;
  public void onUpdate(Context context, AppWidgetManager appWidgetManager,int[] appWidgetIds){
            super.onUpdate(context, appWidgetManager, appWidgetIds);
            this.appWidgetIds = appWidgetIds;
            this.appWidgetManager = appWidgetManager;
            this.context = context;
            Intent intent = new Intent(context,MyLocation.class);
            context.startService(intent);
           // views.setTextViewText(R.id.tvMsg, "text");
//appWidgetManager.updateAppWidget(appWidgetIds, views);
    }
}


service:
public class MyLocation extends Service{
public ArrayList<String> locationArr = new ArrayList<String>();
LocationManager lm;
LocationListener ll = new LocationListener() {
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onProviderEnabled(String provider) {
Location l = lm.getLastKnownLocation(provider);
updtateView(l);
}
@Override
public void onProviderDisabled(String provider) {
updtateView(null);
}
@Override
public void onLocationChanged(Location location) {
updtateView(location);
}
};
@Override
public void onCreate() {
super.onCreate();
        lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
        //设置查询条件
        String bestProvider = lm.getBestProvider(getCriteria(), true);
        //获取位置
        Location l = lm.getLastKnownLocation(bestProvider);
        updtateView(l);
        //设置监听器
        lm.requestLocationUpdates(bestProvider,5000,8,ll);
}
    //编写查询条件的方法
    public Criteria getCriteria(){
    Criteria criteria = new Criteria();
    criteria.setAccuracy(Criteria.ACCURACY_COARSE);//设置查询精度
    criteria.setSpeedRequired(false);//设置是否要求速度
    criteria.setCostAllowed(false);//设置是否产生费用
    criteria.setBearingRequired(false);//设置是否得到方向
    criteria.setAltitudeRequired(false);//设置是否得到海拔高度
    criteria.setPowerRequirement(Criteria.POWER_LOW);//设置运行的电池级别
    return criteria;
    }
    public void updtateView(Location newLocation){
    if (newLocation!=null) {
    locationArr.add(String.valueOf(newLocation.getLatitude()));//添加纬度
    locationArr.add(String.valueOf(newLocation.getLongitude()));//添加经度
}else {
locationArr.add("没有获取您的位置");
}
    }
    public ArrayList<String> getMessage(){
    if (locationArr!=null) {
    return locationArr;
}else {
return null;
}
    }

    @Override
public IBinder onBind(Intent intent) {
return null;
}

@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
RemoteViews views = new RemoteViews(this.getPackageName(),
                R.layout.firstappwidget);
String content = "您的位置:"+"\n"+"纬度:"+getMessage().get(0)+
          "\n"+"经度:"+getMessage().get(1);
views.setTextViewText(R.id.tvMsg,content);
ComponentName thisWidget = new ComponentName(this,MyAppWidgetProvider.class);
AppWidgetManager manager = AppWidgetManager.getInstance(this);
manager.updateAppWidget(thisWidget, views);
}

public String getTime(){
Time myTime = new Time();
myTime.setToNow();
return myTime.format("%H:%M:%S");
}
    @Override
    public void onDestroy() {
    super.onDestroy();
    }
}

系统配置文件:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="sunny.app"
      android:versionCode="1"
      android:versionName="1.0">


    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <receiver android:name=".MyAppWidgetProvider">
            <meta-data android:name="android.appwidget.provider"
                    android:resource="@xml/appwidget_provider" />
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
        </receiver>
        <service android:name="sunny.app.MyLocation"/>
    </application>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOACTION"/>
    <uses-permission android:name="android.permission.UPDATE_DEVICE_STATS"/>
    <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>
    <uses-permission android:name="android.permission.INTERNET"/>
</manifest>



<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
    android:minWidth="200dp"
    android:minHeight="100dp"
    android:updatePeriodMillis="1000"
    android:initialLayout="@layout/firstappwidget"/>

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
   
    <TextView
        android:id="@+id/tvMsg"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textSize="21dp"
        android:textColor="#FFFFFF"
        android:background="@drawable/background_shape"/>
</LinearLayout>

    
[3] objective-c md5事例
    来源: 互联网  发布时间: 2014-02-18
objective-c md5例子

转自:http://www.cnblogs.com/tracy-e/archive/2011/04/13/1877351.html

 

 

@interface NSString (MyExtensions)

- (NSString *) md5;

@end

 

@implementation NSString (MyExtensions)

- (NSString *) md5

{

    const char *cStr = [self UTF8String];

    unsigned char result[16];

    CC_MD5( cStr, strlen(cStr), result ); // This is the md5 call

    return [NSString stringWithFormat:

 @"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",

result[0], result[1], result[2], result[3], 

result[4], result[5], result[6], result[7],

result[8], result[9], result[10], result[11],

result[12], result[13], result[14], result[15]

];  

}

@end

 


    
最新技术文章:
▪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