gedit ~/.bashrc
The last line, comment out the source/opt/ros/kinetic/setup. Bash (adding #)
gedit ~/.bashrc
The last line, comment out the source/opt/ros/kinetic/setup. Bash (adding #)



after completing the above steps
When the Activity’s launch mode is singleTask or singleInstance. If an intent is used to pass a value, then the problem may arise that the intent’s value cannot be updated. That is, the value received for each Intent is the value received for the first time. Because the intent has not been updated. To update, you need to do two things.
1. Add a sentence to the sender Activity
PendingIntent pendingIntent = PendingIntent.getActivity(context,0,intent,PendingIntent.FLAG_UPDATE_CURRENT);
2. The receiving Activity, plus a function, calls the method setIntent
protected void onNewIntent(Intent intent) {
Log.i(TAG,"onNewIntent()");
super.onNewIntent(intent);
setIntent(intent);
int value = getIntent().getIntExtra("value_key", 0);
Log.i(TAG,"value = "+value);
}
Reproduced in: https://www.cnblogs.com/davesuen/p/3703436.html
The Android Android. Intent. The category. The purpose and use of the LAUNCHER
Sometimes we just create a new Android project in Eclipse, run it, and then we have an APK on the phone with the logo; We seldom consider no icon apk, however, this is to say the android. Intent. The category. The LAUNCHER.
1: we see first with android. The intent. The category. The effect of the project after the operation the LAUNCHER
1.1: project name as
1.2: the manifest. XML is as follows: (note contains android. The intent. The category. The LAUNCHER)

1.3: After running the effect, you can see the screen shot of the phone (you can see there is a launcher (CP3))

2: we can’t see with android. Intent. The category. The effect of the project after the operation the LAUNCHER
2.1: project name as
2.2: the manifest. XML is as follows: (note that there is no android. The intent. The category. The LAUNCHER)
2.3: after the operation, you can see on the screen without any effect
2.4 console display as follows:
indeed installed.
2.5: this time we enter the verify directory:

You can see that it contains com.tcl.cp3-2.apk.
1 and 2 contrast can be found in the android. Intent. The category. The role of the LAUNCHER.
Bundle bundle = new Bundle();
bundle.putInt(EXAM_CENTER_TYPE, EXAM_CENTER_1);
toActivity(ExamTypeActivity.class, bundle);
protected void toActivity(Class<?> clazz, Bundle bundle) {
Intent intent = new Intent();
intent.setClass(this, clazz);
if (bundle != null) {
intent.putExtras(bundle);
}
startActivity(intent);
}
Value code:
protected Bundle getExtra() {
Intent intent = getIntent();
if (intent != null) {
return getIntent().getExtras();
} else {
return null;
}
}
protected String getExtraString(String key) {
Bundle bundle = getExtra();
if (bundle != null) {
return bundle.getString(key);
} else {
return "";
}
}
protected int getExtraInt(String key) {
String extra = getExtraString(key);
return NumberUtils.getInt(extra);
}
GetExtraaint (EXAM_CENTER_TYPE) cannot get a value. The reason is that the data type passed to PUT must be the same as that of GET. If you put is a string, get is a string. The getExtraint function can be changed to the following function:
protected int getExtraInt(String key) {
Bundle bundle = getExtra();
if (bundle != null) {
return bundle.getInt(key);
} else {
return 0;
}
}
0:
Default value, if the described PendingIntent already exists, then keep it without change.
FLAG_CANCEL_CURRENT:
For use with a Flag with the getActivity (Context, int, Intent, int) code>, getBroadcast (Context, int, Intent, int) code>, and getService (Context, int, Intent, int) code> : if the described PendingIntent already exists, the current one is canceled before generating a new one. You can use this to retrieve a new PendingIntent when you are only changing the extra data in the Intent; By canceling the previous pending intent, this ensures that only entities given the new data will be able to launch it. If this assurance is not an issue, consider FLAT_Update_current
Constant Value: 268435456 (0 x10000000)
FLAG_NO_CREATE:
For use with a Flag with the getActivity (Context, int, Intent, int) code>, getBroadcast (Context, int, Intent, int) code>, and getService (Context, int, Intent, int) code> : if the described PendingIntent does not already exist, then simply return null instead of creating it.
Constant Value: 536870912 (0 x20000000)
FLAG_ONE_SHOT:
For use with a Flag with the FLAG_UPDATE_CURRENT: For use with a Flag with the Constant Value: 134217728 (0 x08000000) getActivity (Context, int, Intent, int) code>, getBroadcast (Context, int, Intent, int) code>, and getService (Context, int, Intent, int) code> : This PendingIntent can only be used once. If set, after send()
getActivity (Context, int, Intent, int) code>, getBroadcast (Context, int, Intent, int) code>, and getService (Context, int, Intent, int) code> : if the described PendingIntent already exists, then keep it but its replace its extra data with what is in this new Intent. This can be used if you are creating intents where only the extras change, and don't care that any entities that received your previous PendingIntent will be able to launch it with your new extras even if they are not explicitly given to it.
The Intent solution cannot be updated in the onRestart method
Override the change method in the Activity
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
// must store the new intent unless getIntent() will return the old one
setIntent(intent);
}



It is disgusting to encounter this exception. In Tomcat7 environment, this exception will be raised if the user’s name appears in Chinese when logging in. After the exception is caused, the user who cannot log in normally needs to delete the browser’s cookie information. Later, I checked the Internet and found out that the problem was Chinese transcoding. The abnormal information is as follows:
java.lang.IllegalArgumentException: Control character in cookie value or attribute.
at org.apache.tomcat.util.http.CookieSupport.isV0Separator(CookieSupport.java:155)
at org.apache.tomcat.util.http.Cookies.processCookieHeader(Cookies.java:323)
at org.apache.tomcat.util.http.Cookies.processCookies(Cookies.java:157)
at org.apache.tomcat.util.http.Cookies.getCookieCount(Cookies.java:98)
at org.apache.catalina.connector.CoyoteAdapter.parseSessionCookiesId(CoyoteAdapter.java:913)
at org.apache.catalina.connector.CoyoteAdapter.postParseRequest(CoyoteAdapter.java:683)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:400)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:304)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Cookie is encoded by Unicode in Chinese and ASCII in English when storing the value, so the data needs to be transcoded when storing the Chinese value, and the data also needs to be transcoded when storing the value.
There are two solutions, one is a Cookie written in Java, and the other is a Cookie written in JavaScript.
The solution is as follows:
Java:
Encode: URLEncoder. Encode (name, “UTF-8”);
Decode.decode (name, “UTF-8”);
Decode.decode (name, “UTF-8”);
JavaScript:
Code: the escape (name);/encodeURI(name);
decode: unescape(name);/decodeURI(name);
The Servlet setting cookies to view the article: http://blog.csdn.net/twilight041132/article/details/46482983
Many people often make this mistake when learning cookies. Someone asked me this question today, so I will share with you the solution to this problem (there is no specific solution on the Internet).
error code:
Cookie cookie=new Cookie("name","value value2");
response.addCookie(cookie);
Error
Java. Lang. IllegalArgumentException: An invalid character [32] was present in the Cookie value
Error code:
Cookie c=new Cookie("name","value,value2");
response.addCookie(c);
Error:
Java. Lang. IllegalArgumentException: An invalid character [44] was present in the Cookie value
…
the exception can be seen that this problem belongs to the invalid parameters, looking at the back of the prompt content
the An invalid character [44] was present in the Cookie value
cookies are invalid characters in character [44], so we query ASCII code is 44 said
“, “said 32 Spaces so we only need to replace the value of the corresponding characters, or coding
in our store String value or a json String to the cookies first pass validateCookieValue this method, as shown below
private void validateCookieValue(String value) {
int start = 0;
int end = value.length();
if (end > 1 && value.charAt(0) == '"' && value.charAt(end - 1) == '"') {
start = 1;
end--;
}
char[] chars = value.toCharArray();
for (int i = start; i < end; i++) {
char c = chars[i];
if (c < 0x21 || c == 0x22 || c == 0x2c || c == 0x3b || c == 0x5c || c == 0x7f) {
throw new IllegalArgumentException(sm.getString(
"rfc6265CookieProcessor.invalidCharInValue", Integer.toString(c)));
}
}
}
we take a look at this way, when do array with value value to each of these characters is verified, which, according to the theory of the if statement is an exception is thrown directly, so there will be a we Control character in the cookie value or attribute. Among them, 0x21 and 0x22 are hexadecimal representation numbers, and the corresponding positions are 33 and 34 respectively;
First of all, do cookies contain ASCII encoding?Then we use GBK or UTF-8 encoding when we use parsing. When it comes to ASCII code 0X21 and 0X22, what is the corresponding character?We need to check the ASCII code comparison table. OK, let’s look at the corresponding ASCII table
In
, the two marked in red are randomly specified. I believe you will know why you reported that exception after reading the picture you bought.
br>>
lencoder. Encode (name, “UTF-8 “)
Urlencoder. Encode (name,” UTF-8 “)
Urlencoder.
URLDecoder.decode(cookies[i].getName(),”utf-8″)