Main Code Of Android Usefull Tips

To Start Another App's Activity

	try{
		ComponentName cnActivity=new ComponentName("com.kingsoft","com.kingsoft.StartActivity");//com.kingsoftStartActivity
		Intent intentTemp=new Intent();
		intentTemp.setComponent(cnActivity);
		intentTemp.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		startActivity(intentTemp);
	}catch(Exception e){
		fAlert("Not Found => "+e.toString());
	}

To Set A Alarm

	AlarmManager amTemp22=(AlarmManager)getSystemService(ALARM_SERVICE);
	amTemp22.set(AlarmManager.RTC_WAKEUP,System.currentTimeMillis()+7000,PendingIntent.getService(this,0,new Intent(this,AnotherService.class),0));

To Set Wallpaper

	try{
		setWallpaper(new FileInputStream(Public.sdSDCard+"/admin/whisper/picture/about/ChenJinyan/b.jpeg"));
	}catch(Exception e){
		fAlert("Error In The Stream Of Picture => "+e.toString());
	}

To Start Some Activities

	Intent iTemp=new Intent();
	iTemp.setAction("android.intent.action.MAIN");
	iTemp.addCategory("android.intent.category.LAUNCHER");
	iTemp.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
	startActivity(iTemp);

OR

	Intent iTemp=new Intent();
	iTemp.setAction("android.intent.action.MAIN");
	iTemp.addCategory("android.intent.category.DEFAULT");
	iTemp.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
	startActivity(iTemp);


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
解释以下代码ISR(PCINT2_vect) { uint8_t mask; uint8_t pin; uint16_t cTime,dTime; static uint16_t edgeTime[8]; static uint8_t PCintLast; pin = PIND; mask = pin ^ PCintLast; // doing a ^ between the current interruption and the last one indicates wich pin changed sei(); // re enable other interrupts at this point, the rest of this interrupt is not so time critical and can be interrupted safely PCintLast = pin; // we memorize the current state of all PINs [D0-D7] cTime = micros(); // micros() return a uint32_t, but it is not usefull to keep the whole bits => we keep only 16 bits if (mask & 1<<2) { //indicates the bit 2 of the arduino port [D0-D7], that is to say digital pin 2, if 1 => this pin has just changed if (!(pin & 1<<2)) { //indicates if the bit 2 of the arduino port [D0-D7] is not at a high state (so that we match here only descending PPM pulse) dTime = cTime-edgeTime[2]; if (900<dTime && dTime<2200) rcValue[2] = dTime; // just a verification: the value must be in the range [1000;2000] + some margin } else edgeTime[2] = cTime; // if the bit 2 of the arduino port [D0-D7] is at a high state (ascending PPM pulse), we memorize the time } if (mask & 1<<4) { //same principle for other channels // avoiding a for() is more than twice faster, and it's important to minimize execution time in ISR if (!(pin & 1<<4)) { dTime = cTime-edgeTime[4]; if (900<dTime && dTime<2200) rcValue[4] = dTime; } else edgeTime[4] = cTime; } if (mask & 1<<5) { if (!(pin & 1<<5)) { dTime = cTime-edgeTime[5]; if (900<dTime && dTime<2200) rcValue[5] = dTime;//map(dTime,1016,2020,-128,128); } else edgeTime[5] = cTime; } if (mask & 1<<6) { if (!(pin & 1<<6)) { dTime = cTime-edgeTime[6]; if (900<dTime && dTime<2200) rcValue[6] = dTime;//map(dTime,1016,2020,-128,128); } else edgeTime[6] = cTime; } }
07-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值