## programming languages – My App Keeps o Stopping and there is an exception there

I Have Tried To Rebuild the project but nothing Happened

My Code Is Down

`

``````        save_time.setOnClickListener {
val medicine = medicinea.text.toString()

val days = arrayOf("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday")

val editor = shrd.edit()
editor.putString("medicine", medicine)
editor.putString("day", day_selected)
editor.putString("whenSelected", when_selected)
editor.putString("medicineSelected", medicine_selected)
editor.putString("time", time_selected)
editor.apply()
Toast.makeText(this@Add, "Saved To Internal Database", Toast.LENGTH_SHORT).show()
}
}

if (day_selected.toString() == "Friday") {
val intent = Intent(this, Friday::class.java)
startActivity(intent)

}

if (day_selected.toString() == "Saturday") {
val intent = Intent(this, Saturday::class.java)
startActivity(intent)
}
if (day_selected.toString() == "Sunday") {
val intent = Intent(this, Sunday::class.java)
startActivity(intent)

}
if (day_selected.toString() == "Monday") {
val intent = Intent(this, Monday::class.java)
startActivity(intent)
}

if (day_selected.toString() == "Tuesday") {
val intent = Intent(this, Tuesday::class.java)
startActivity(intent)
}
if (day_selected.toString() == "Wednesday") {
val intent = Intent(this, Wednesday::class.java)
startActivity(intent)
}
if (day_selected.toString() == "Thursday") {
val intent = Intent(this, Thursday::class.java)
startActivity(intent)
}

}`
``````

From here if i go to Friday activity

`````` package com.example.medicaltimetableapp

import android.content.Context
import com.example.medicaltimetableapp.R
import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.view.View
import android.widget.TextView
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatActivity
import androidx.constraintlayout.widget.ConstraintSet
import kotlinx.android.synthetic.main.activity_friday.*
import kotlinx.android.synthetic.main.activity_main.view.*

class Friday : AppCompatActivity() {

@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_friday)

val layout = fridaylayout

val constraintSet = ConstraintSet().apply {
clone(layout)
connect(R.id.dayf, ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP)
connect(R.id.dayf, ConstraintSet.RIGHT, ConstraintSet.PARENT_ID, ConstraintSet.RIGHT)
}
constraintSet.applyTo(layout)

medicineview!!.x = +100F
val constraintSet1 = ConstraintSet().apply {
clone(layout)
connect(R.id.medicinef, ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP)
connect(R.id.medicinef, ConstraintSet.RIGHT, ConstraintSet.PARENT_ID, ConstraintSet.RIGHT)
}
constraintSet.applyTo(layout)

whenselview!!.x = +200F
val constraintSet2 = ConstraintSet().apply {
clone(layout)
connect(R.id.whenf, ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP)
connect(R.id.whenf, ConstraintSet.RIGHT, ConstraintSet.PARENT_ID, ConstraintSet.RIGHT)
}
constraintSet.applyTo(layout)

mediselview!!.x = +300F
val constraintSet3 = ConstraintSet().apply {
clone(layout)
connect(R.id.howmuchf, ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP)
connect(R.id.howmuchf, ConstraintSet.RIGHT, ConstraintSet.PARENT_ID, ConstraintSet.RIGHT)
}
constraintSet.applyTo(layout)

timeview!!.x = +400F
val constraintSet4 = ConstraintSet().apply {
clone(layout)
connect(R.id.timef, ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP)
connect(R.id.timef, ConstraintSet.RIGHT, ConstraintSet.PARENT_ID, ConstraintSet.RIGHT)
}
constraintSet.applyTo(layout)

}

private fun add_view(data: String, id: Int): View? {

val text = TextView(applicationContext)
text.setBackgroundColor(Color.rgb(255, 229, 229))
text.width = 100
text.height = 50
text.x = 21F
text.y = 88F
text.id = id
text.text = data

return text
}
``````

}

And I Get This Exception

``````E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.medicaltimetableapp, PID: 24254
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.medicaltimetableapp/com.example.medicaltimetableapp.Tuesday}: java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.constraintlayout.widget.ConstraintLayout.addView(android.view.View)' on a null object reference
at android.app.ActivityThread$$H.handleMessage(ActivityThread.java:1613) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6523) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:857)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.constraintlayout.widget.ConstraintLayout.addView(android.view.View)' on a null object reference
at com.example.medicaltimetableapp.Tuesday.onCreate(Tuesday.kt:44)
at android.app.Activity.performCreate(Activity.java:7023)
at android.app.Activity.performCreate(Activity.java:7014)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread$$H.handleMessage(ActivityThread.java:1613) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6523) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:857)
``````

My Manifiest File

``````<?xml version="1.0" encoding="utf-8"?>
``````
``````<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity"></activity>
<activity android:name=".Sunday" />
<activity android:name=".Saturday" />
<activity android:name=".Friday" />
<activity android:name=".Thursday" />
<activity android:name=".Wednesday" />
<activity android:name=".Tuesday" />
<activity android:name=".Monday" />
<activity android:name=".homeanimation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
``````

I’m working on putting together an application for Raspberry Pi 3. I have experience in other languages but Python has never been a favorite of mine, thus haven’t used it much.

The threading portion involves serial communication and queuing both input and output. I’ve successfully put together a small stand-alone script that successfully does everything I want.

The problem is converting this to a class, as I haven’t yet found a way to successfully kill the threads I’ve started there. The parts I’ve written seem to work the same as the stand-alone script I made first. Using a flag to indicate when to terminate the threads worked there but doesn’t seem to in the class. Is this a scoping thing? I thought I tried using a global as well, but it may be my ignorance of the language nuances creeping in.

I’m looking for either a way to restructure this achieving the same effect, or (better) just a way to stop the threads.

The script for testing the class is very simple, with a few things I’ve tried commented out:

``````foo = bar.Bar()
#time.sleep(5)
#foo.stop()
#del foo
#exit()
``````

Trying to whittle down the class to the relevant essentials (always tough to do…):

``````import time
import serial
import queue

global main_running

class Bar(object):

### A bunch of constants here

def __init__(self, com_port='/dev/ttyS0'):
global main_running

self._serial_rx_queue = queue.Queue()
self._serial_tx_queue = queue.Queue()

self._foobar_port = serial.Serial(
port = com_port,
baudrate = 14400,
parity = serial.PARITY_NONE,
stopbits = serial.STOPBITS_ONE,
bytesize = serial.EIGHTBITS,
timeout = 1
)

main_running = True
#self._main_running = True

###### NOT WORKING - THREADS NEVER DIE!
def stop(self):
global main_running

self._foobar_port.close()
main_running = False
#self._main_running = False

###### ALSO NOT WORKING - THREADS NEVER DIE!
#    # Destructor
#    def __del__(self):
#        self._foobar_port.close()
#        self._main_running = False
#

### A bunch of application specific message encoding/decoding

global main_running

while(self._foobar_port.isOpen() and (main_running == True)):
if(self._foobar_port.in_waiting):

if(self._foobar_port.isOpen()):

### Application specific code to process data read

time.sleep(0.01)

global main_running

while(self._foobar_port.isOpen() and (main_running == True)):
while(self._serial_tx_queue.empty() and (main_running == True)):
time.sleep(0.01)

message = self._serial_tx_queue.get()
print('>>> ', message)

if(self._foobar_port.isOpen()):
self._foobar_port.write(message)

time.sleep(0.1)

global main_running

#        while self._main_running:
while main_running == True:

self._serial_tx_queue.put('dummy message for illustration')

time.sleep(1)
$$```$$
``````

## bitcoin core – Stopping bitcoind on mac

One of my kids while learning more about bitcoin started bitcoind on my mac. Now I am unable to stop it. In my activity monitor, it shows a process named “bitcoind”. I have stopped that process from the activity monitor various times but that doesn’t help. It starts again after some time or in the next boot session. It has been taking a lot of my laptop space (>100gb). I am running low on space and I need to stop it now. This has been happening regularly. As a temporary solution, I used to go to /Users/(name)/Library/Application Support/ and delete the “Bitcoin” folder from there. But that’s no proper solution to end it completely. I have tried a bunch of stuff using bitcoin-cli in the terminal. However, I am unable to stop it.

Running
`bitcoin-cli stop` returns `error: couldn't connect to server: unknown (code -1) (make sure server is running and you are connecting to the correct RPC port)`.

Can someone please tell me what should I do to stop the bitcoind?

## sql server – Disconnect from network without stopping the query

Not directly using normal tools (SSMS etc.) and access libraries – if you disconnect progress should stop and any active transactions will get rolled back.

You could run the statements via an agent job set to start immediately, assuming that this is configured and your login has sufficient privileges.

## postgresql – Stopping cascading logical replication

Give two primary PG12 servers, A and B, let’s setup logical replication from A to B.

`A --> B`

Both servers can and do receive writes, and don’t use sequences or unique constraints so there is no conflict.

Is it possible to set up replication from B to A, without replicating the data replicated from A?

Writes from A:
`A --> B -x-> A`

Writes from B:
`B --> A -x-> B`

End result is both databases have the same data set.

## stochastic processes – Optimal rule for multiple stopping times for defect finding

Suppose a quality inspector is inspecting $$b$$ black and $$w$$ white gadgets. It is known in advance that there are in total $$d_b$$ defective black and $$d_w$$ white gadgets. The device comes down along an assembly line one by one. As each gadget passes, the inspector observes its color, and he chooses to let the gadget pass or use a device to detect whether the gadget is defective. But he can only use the device a total of $$n$$ times. What is the optimal stopping rule to use the inspecting device to maximize the expected number of defective gadgets found.

=====

Suppose at each pass the number of black gadgets already device inspected is $$i_b$$, amongst them $$f_b$$ are detected to be defective. Then the probability of this current black gadget detected to be defective is $$p_b=frac{d_b-f_b}{b-i_b}$$. Symmetrical probability holds for the white gadgets.

I have a conjecture for the explicit solution, which is a greedy algorithm, as follows and am seeking a proof.

At each pass of the gadget, the inspector waits for the gadget with the color to show up with the defect probability equal to $$p:=max(p_b, p_w)$$ to inspect with the device unless the number of device usages left is greater than the number of gadgets the defective probability of which equals to $$p$$.

I have set up the dynamic programming formulation but fail to see immediately either the proof or a counterexample to my conjecture.

## Is it possible to turn off the screen without stopping foreground activity?

Let’s suppose I’m playing an idle game where things inside only happen when the game is running in foreground, or listening to music on YouTube, which also must be running in foreground to work. But when the screen is locked (turned off), all foreground activity gets suspended. Is there a way (like some 3rd party software) to somehow just turn off the screen (maybe even without locking the touch surface functioning) so that it wouldn’t drain power and the foreground app would still work?

## samsung – Google play services keeps stopping, and it is much worse than normal

My Samsung Galaxy J7 (2016 version) is constantly showing “Google play services keeps stopping” every 2~3 seconds. My device is running on android Oreo. I tried reverting back playstore to factory version, now I can’t even enter playstore. It just keeps loading forever. I am unable to uninstall play services as well, neither can I delete the data. Yes I did try to deactivate the “find my device’ option, but upon tapping “deactivate”, the whole option gets greyed out and nothing happens.

I’m not being able to do anything on my phone, and its driving me crazy. Any sort of help would be highly appreciated 🙂

## How to fix my android 7.0 after i factory reset it amd open the device the start up wizard keeps on stopping now i cant open my device

After i encrypt my phone it didnt went well because i pulled out the battery i reopen it and the device said that i need to factory reset it after doing factory reset i oppened my phone and after clicking the get started the device keeps saying that start up wizard keeps stopping and now i cant open my phone and cant use it I tried to factory reset it again but still it wasnt working what should i do?

## stochastic processes – Correlation of stopping times for integral of Brownian motion increment

Let $$mu(x):=int_{epsilon}^{x}exp{B_{s+epsilon}-B_{s-epsilon}}ds$$, where $$(B_{s})_{sgeq 0}$$ is a Brownian motion (starting at $$B_{0}=0$$) and epsilon is small $$0. Consider the stopping time

$$T_{a}:=inf{tgeq epsilon: mu(t)geq a },text{ for ageq 0.}$$

For “good” deterministic choices $$a and $$t_{1},t_{2}geq 0$$ we are studying the correlation of

$${T_{b}-T_{a}geq t_{1}}text{ and }{T_{d}-T_{c}geq t_{2}}.$$

Q: One approach is by studying a mixing condition: trying to estimate the difference

$$| P({T_{d}-T_{c}geq t_{2}, T_{b}-T_{a}geq t_{1}})-P({T_{d}-T_{c}geq t_{2}} )cdot P( {T_{b}-T_{a}geq t_{1}})|$$
when $$(a,b)$$ and $$(c,d)$$ are distant enough. In other words, we are trying to find whether there are any constraints on $$a so that the above difference goes to zero.

If you think this question is ill-posed or too obvious for Mathoverflow, please put your hint in the comments and I will delete the question.

Approach

The process $$mu(x)$$ is not Markov because of the $$B_{s-epsilon}$$ term and so strong Markov property (SMP) doesn’t apply. But in the spirit of (SMP), we introduce the event

$$E:={T_{c}> T_{b}+2epsilon}.$$

So just for the sake of understanding (even if we can’t get a good control on $$E^{c}$$), lets focus on the above difference with the first term intersected with $$E$$:
$$| P({T_{d}-T_{c}geq t_{2}, T_{b}-T_{a}geq t_{1}}cap E)-P({T_{d}-T_{c}geq t_{2}} )cdot P( {T_{b}-T_{a}geq t_{1})|.$$

I will update as I find things.