Author Archives: Robins

bash: /opt/ros/kinetic/ setup.bash : there is no file or directory

I installed ROS Melodic version, but I used the installation tutorial of “Kinetic” version. As a result, I forgot to change “Kinetic” into “Melodic” in the tutorial by using the echo command when adding environment variables at one step, so the following phenomena occurred:

An error occurred when I source ~/.bashrc
Bash:/opt/ros/kinetic/setup. Bash: no files or directories

After looking, I use the command
tlf@tanglifan:~$ gedit ~/.bashrc

At the bottom of a add error source: the source/opt/ros/kinetic/setup. Bash
Delete it and save it. It’s back to normal.

Idea installation vue.js After plug-in, new has no Vue component

New does not have a Vue Component after installing the Vue.js plugin
First to install the vue related plug-in vue. Js

a lot of people in after installing the vue plug-in, right-click the new found no vue component this option. As follows:

Solution:
Settings> Editor> File and Code Templates
after completing the above steps
,

right click new again at this time, found that option in the Vue Component

The reason and solution of Android intent value not updated

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

Android android.intent.category Purpose and use of. Launcher

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.

Android can’t transfer value when using extras, bundle and intent

Working environment (bold blue for special attention)
1, System environment: Win7 Ultimate SP1, Android Studio 3.2
Oddly enough, today when a Bundle is used to pass values between activities, it is not possible to get the value passed in. Look at the pass-value code:

 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;
        }
    }

 
 

The problem that the content extra data in the notification cannot be updated

Recently younger brother when writing a find out about the background data processing service within the PendingIntent NotificationManager to send the Notification of the Intent of the Extra data cannot update, unable to get even, after tests found that the same ID Notification first Intent can only be stored data, even if use the NotificationManager. Cancel also of no help.
Found after examined the related API, use the PendingIntent. GetActivity (mContext, 0, mActivity, 0); After the Notification is opened, the target Activity cannot retrieve any additional data from getIntent(). Set the flag of the getActivity function to either pendingintent.flag_update_current or pendingintent.flag_cancel_current according to the API.
Also put a PendingIntent, getActivity function can be used in several flag value meaning:

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) , getBroadcast (Context, int, Intent, int) , and getService (Context, int, Intent, int) : 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) , getBroadcast (Context, int, Intent, int) , and getService (Context, int, Intent, int) : 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 getActivity (Context, int, Intent, int) , getBroadcast (Context, int, Intent, int) , and getService (Context, int, Intent, int) : This PendingIntent can only be used once. If set, after send()

FLAG_UPDATE_CURRENT:

For use with a Flag with the getActivity (Context, int, Intent, int) , getBroadcast (Context, int, Intent, int) , and getService (Context, int, Intent, int) : 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.

Constant Value: 134217728 (0 x08000000)

Illegalargumentexception: control character in cookie value or attribute tomcat7

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

Illegalargumentexception error when adding cookie to response

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

Parsing the exception of storing JSON string in cookie

Exception caused by a JSON string is stored in a cookie

Control character in cookie value or attribute exception, or An invalid character [34] was present in the cookie value exception, etc. So how to solve such a problem, let’s follow the code step by step to look at

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″)