Category Archives: How to Fix

Unity3d mount script error “can’t add script behavior TMP”_ CoroutineTween. …”

“Can’t add script behaviour TMP_ CoroutineTween. The script needs to derive from MonoBehaviour!”

If you can’t hang up the script when you hang up the game object in unity3d, the above error occurs, and the previously hung script can’t be hung back after being cancelled, then you may have the same problem as me

There is a compilation error in a script…

If it’s done, it’s done.

Sending message to a handler on a dead thread

The slightly more subtle message is: handler( android.os.Handler ) {215ddea8} sending message to a Handler on a dead thread。

In another case, when using mediaplayer in intentservice to play the ring tone, the error is also reproduced. The message is: handler) {42414500} sending message to a handler on a dead thread.

The complete information is as follows:

W/ActivityManager( 1394): getTasks: caller 10034 is using old GET_ TASKS but privileged; allowing

W/MessageQueue( 7666): Handler ( android.os.Handler ) {215ddea8} sending message to a Handler on a dead thread

W/MessageQueue( 7666): java.lang.IllegalStateException : Handler ( android.os.Handler ) {215ddea8} sending message to a Handler on a dead thread

W/MessageQueue( 7666):  at android.os.MessageQueue .enqueueMessage( MessageQueue.java:325 )

W/MessageQueue( 7666):  at android.os.Handler .enqueueMessage( Handler.java:635 )

W/MessageQueue( 7666):  at android.os.Handler .sendMessageAtTime( Handler.java:604 )

W/MessageQueue( 7666):  at android.os.Handler .sendMessageDelayed( Handler.java:574 )

W/MessageQueue( 7666):  at android.os.Handler .postDelayed( Handler.java:398 )

W/MessageQueue( 7666):  at com.bandwidthx.library .l.a(S ourceFile:367 )

W/MessageQueue( 7666):  at com.bandwidthx.library .l.B(S ourceFile:357 )

W/MessageQueue( 7666):  at com.bandwidthx.library . BxApproval.aZ (S ourceFile:4563 )

W/MessageQueue( 7666):  at com.bandwidthx.library . BxApproval.aT (S ourceFile:4440 )

W/MessageQueue( 7666):  at com.bandwidthx.library . BxApproval.aS (S ourceFile:4431 )

W/MessageQueue( 7666):  at com.bandwidthx.library . BxApproval.aG (S ourceFile:4044 )

W/MessageQueue( 7666):  at com.bandwidthx.library .l.a(S ourceFile:1320 )

W/MessageQueue( 7666):  at com.bandwidthx.library .l.j(S ourceFile:1275 )

W/MessageQueue( 7666):  at com.bandwidthx.library .q.w(S ourceFile:2280 )

W/MessageQueue( 7666):  at com.bandwidthx.library .q.a(S ourceFile:3399 )

W/MessageQueue( 7666):  at com.bandwidthx.library .q.a(S ourceFile:3103 )

W/MessageQueue( 7666):  at com.bandwidthx.library .q$1.a(S ourceFile:1959 )

W/MessageQueue( 7666):  at com.bandwidthx.library .q$1.doInBackground(S ourceFile:1928 )

W/MessageQueue( 7666):  at android.os.AsyncTask $2.call( AsyncTask.java:292 )
W/MessageQueue( 7666):  at java.util.concurrent . FutureTask.run ( FutureTask.java:237 )

W/MessageQueue( 7666):  at android.os.AsyncTask $SerialExecutor$1.run( AsyncTask.java:231 )

W/MessageQueue( 7666):  at java.util.concurrent . ThreadPoolExecutor.runWorker ( ThreadPoolExecutor.java:1112 )

W/MessageQueue( 7666):  at java.util.concurrent .ThreadPoolExecutor$ Worker.run ( ThreadPoolExecutor.java:587 )

W/MessageQueue( 7666):  at java.lang.Thread .run( Thread.java:818 )

It’s estimated that looper, message queue and so on have been rotten by you.

 

I’ll just give you a brief summary (of course, there are also very detailed ones below)

Once a thread’s message loop exits, it can no longer send messages to it, otherwise runtimeException will be thrown.
That’s what you see in general:

"RuntimeException: Handler{xxxx} sending message to a Handler on a dead thread"。

Generally speaking, if you implement your own looper and handler, it is recommended that Looper.prepare After (), call Looper.myLooper () to get a reference to the thread looper.
Purpose: 0. You can call quit() to terminate the service thread. 1. When receiving a message, check whether the message loop has exited

 

It is worth mentioning that the thread is terminated. Sometimes it is not terminated by yourself. It may be caused by some normal timing of the system (you just don’t pay attention to this sequence, and then you don’t pay attention to it when writing code)


 

The above has been made clear, and the following is the detailed information & amp; wordy demarcation line

 

Case: (using intentservice to send SMS, the code is as follows)

Inside the intentservice, it is actually a worker thread opened.

@Override
protected void onHandleIntent(Intent intent) {
    Bundle data = intent.getExtras ();
    String[] recipients = null;
    String message = getString(R. string.unknown_ event);
    String name = getString(R. string.app_ name);
    if (data != null && data.containsKey ( Constants.Services.RECIPIENTS )) {
        recipients = data.getStringArray ( Constants.Services.RECIPIENTS );
        name = data.getString ( Constants.Services.NAME );
        message = data.getString ( Constants.Services.MESSAGE );
        for (int i = 0; i < recipients.length ; i++) {
            if(! StringUtils.isNullOrEmpty (recipients[i])) {
                try {
                    Intent sendIntent = new Intent(this, SMSReceiver.class );
                    sendIntent.setAction ( Constants.SMS.SEND_ ACTION);
                    PendingIntent sendPendingIntent = PendingIntent.getBroadcast (getApplicationContext(), 0, sendIntent, PendingIntent.FLAG_ UPDATE_ CURRENT);
                    Intent deliveryIntent = new Intent(this, SMSReceiver.class );
                    deliveryIntent.setAction ( Constants.SMS.DELIVERED_ ACTION);
                    PendingIntent deliveryPendingIntent = PendingIntent.getBroadcast (getApplicationContext(), 0, deliveryIntent, PendingIntent.FLAG_ UPDATE_ CURRENT);
                    SmsManager.getDefault ().sendTextMessage(recipients[i].trim(), null, “[” + name + “] ” + message, sendPendingIntent, deliveryPendingIntent);
                } catch (Exception e) {
                    Log.e(TAG, “sendTextMessage”, e);
                    e.printStackTrace();
                    Toast.makeText (this, e.getMessage(), Toast.LENGTH_ LONG).show();
                    MainActivity.instance.writeToLogFile (e.getMessage(), System.currentTimeMillis ());                       
                }
            }
        }
    }
}

(people with a clear eye will know that there is something wrong with the catch sentence)

catch (Exception e) {
     Log.e(TAG, "sendTextMessage", e);
     e.printStackTrace();
     Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
     MainActivity.instance.writeToLogFile(e.getMessage(), System.currentTimeMillis());                       
}

It turned out to be a mistake

Google took a look at the information, and the website said:

The reason is that you create a toast in a thread whose life cycle is controlled by intentservice. The phone will display the toast first, and then hide it with the handler of the thread; Close the toast, but when onhandleintent ends, the thread will hang up, and then the handler bound to the thread will not exist, and the toast will not close after the completion. What should I do? Send it to the main thread. The handeler of its toast is still alive. You can hide toast.)

 

What about the solution? (simple, rough)

 


 

What questions do you have to say?

Why send a message to a dead thread?

Because the onhandle intent (intent intent) ends, the thread is gone. What’s going on?

 

Handler is gone, so can’t hide toast?

If I remember correctly, the life cycle of this toast should be controlled by notification manager service, right?

 

(analysis of intentservice source code) — todo

Analysis of toast life cycle source code

The second operation of software engineering

The second operation of software engineering

8.5 The department of public works for a large city has decided to develop a Web-based pothole tracking and repair system(PHTRS). Draw a UML use case diagram for the PHTRS system. You’ll have to make a number ofassumptions about the manner in which a user interacts with this system. A description follows:

Citizens can log onto a website and report the location and severity of potholes. As potholes are reported they are logged with a “public works department repair system” and are assigned an identifying number, stored by street address, size(on a scale of 1 to 10), location(middle, curb, etc.),district(determined from street address), and repair priority(determined from the size of the pothole). Work order data are associated with each pothole and include pothole location and size, repair crew identifying number, number of people on crew, equipment assigned, hours applied to repair, hole status(work in progress, repaired, temporary repair, not repaired), amount of filler material used, and cost of repair (computed from hours applied, number of people, material and equipment used). Finally, a damage file is created to hold information about reported damage due to the pothole and includes citizen’s name, address, phone number, type of damage, and dollar amount of damage, PHTRS is an online system; all queries a to be made interactively.

1. UML use case


8.6 Write two or three use cases that describe the roles of various actors in the PHTRS .

Case 1: filling situation

Participants: Citizens

    when citizens log in to phtrs, they input their account number, and they input two passwords (each at least 8 characters in length). The system displays all the main function buttons. Citizens select “fill in” from the main functions. Citizens fill in the street address, size, location, region, and repair priority. Citizens choose to save. The system assigns an identification number for the fill in and generates an order to be sent to the public works department Staff


Case 2: fill in the worksheet

Participants: construction workers

    when the construction personnel log in phtrs, the construction personnel input the account number, the construction personnel input two passwords (each with a length of at least 8 characters), the system displays all the main function buttons, the construction personnel select “fill in the worksheet” from the main functions, the system displays the work order assigned by the construction personnel, the construction personnel select the corresponding work order, the construction personnel fill in the number of personnel, and the allocated equipment, Repair time, pothole state, filling materials, repair cost and other information submitted by construction personnel


    8.7 Develop an activity diagram for one aspect of PHTRS.

    2. The activity chart of the construction personnel filling in the work sheet


    8.8 Develop a swimlane diagram for one or more aspects of PHTRS.

    3. The construction personnel fill in the swimlane chart of the work sheet

ERROR: pygame-1.9.2-cp35-cp35m-win32.whl is not a supported wheel on this platform.

Why?

The downloaded pyGame is not compatible with the python version.

How do you do it?

Go to the website and download the pyGame installation related to your Python version.
(check your Python version: if you enter Python in CMD, you will be prompted for the python version.)

Process:

When installing pyGame last night, I went to the website: link according to the process in the textbook “Python Programming: from introduction to practice”, and downloaded the corresponding pyGame. However, the above errors occurred during the installation.
Looking all over the network, there is no suitable solution for me.
Then I look at the error report carefully:
pygame-1.9.2-cp35-cp35m-win32.whl is not supported by this platform (wheel, please point out what it is). The previous file is used to install pyGame.
1.9.2 refers to PIP version.
Cp35 refers to Python version 3.5, while mine is 3.7.
So far, the event is clear. Each pyGame corresponds to a different version of Python. The version is incompatible and an error is reported.
After downloading, the installation is successful!
(no screenshots here: I forgot to cut them last night)

File “manage.py“, line 17 ) from exc ^ SyntaxError: invalid syntax

The newly created Django project will run directly after entering

python manage.py runserver

The mistakes are as follows:

user@UserdeMacBook-Pro djangoProject % python manage.py runserver
  File "manage.py", line 17
    ) from exc
         ^
SyntaxError: invalid syntax

I feel a little puzzled. Later, I found that there was a problem with the specification of the python version. I should specify the python 3 version

python3 manage.py runserver

That’s it.

Python error type error: ‘range’ object does not support item assignment, solution

1. Examples are as follows:

from math import sqrt
if __name__ == '__main__':
    N = 100
    a = range(0,N)
    for i in range(2,int(sqrt(N))):
        for j in range(i + 1,N):
            if (a[i] != 0) and (a[j] != 0):
                if a[j] % a[i] == 0:
                        a[j]= 0

    for i in range(2,N):
        if a[i] != 0:
            print ("%5d" % a[i])
            if (i - 2) % 10 == 0:
                print         

Error after execution: typeerror: ‘range’ object does not support item assignment

2. The reasons for the error are as follows:

Try to use range()
to create an integer list (leading to “typeerror: ‘range’ object does not support item assignment”). Sometimes you want to get an ordered integer list, so range() seems to be a good way to generate this list. However, you need to remember that range () returns the “range object” instead of the actual list value.

3. Solutions:

Just change the code of the above example: a = range (0, n) to a = list (range (0, n))!

Solve the problem of multiple root tags in as

In as, multiple root tags usually appear when a piece of code is copied to another space

In the first case, the root tag of the original code is copied when the code is copied. In the second case, the code is not put into a package in another space to check whether the package in another space covers the new code

data argument can’t be an iterator

 b = map(ct,data.as_matrix())

data = pd.DataFrame(b).fillna(0)
Traceback (most recent call last):

  File "<ipython-input-47-48b397cc2c53>", line 1, in <module>
    data = pd.DataFrame(b).fillna(0)

  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\frame.py", line 389, in __init__
    raise TypeError("data argument can't be an iterator")

TypeError: data argument can't be an iterator

Reason: Elements in a dataframe cannot be iterative.

b = map(ct,data.as_matrix())
c = list(b)
data = pd.DataFrame(c).fillna(0)

Unicode decodeerror: ‘UTF-8’ codec can’t decode byte 0x80 in position 3131: invalid start byte solution

The Unicode decodeerror: ‘UTF-8’ codec can’t decode byte 0x80 in position 3131: invalid start byte appears in the process of using Python 3 to read files on Mac OS.

The reason is: OS X system has hidden file. DS in the folder_ Store file, affecting the file read.

.DS_ Store is a hidden file that stores the custom properties of a folder on Mac OS, such as its icon location or background color.

The solution is: use the command line to enter the folder where the file is read and delete. DS_ Store file.

1. Use the command LS – A to view. DS_ Store file

2. rm .DS_ Store。