我有两个应用程序,我试图将一个意图从一个发送到另一个,但意图是永远不会到达,onReceive()
但这个问题只是一种方式.第一个应用程序可以发送到第二个,但第二个不能发回信息.我使用不同的意图动作从第二个发送到第一个,但否则它们是相同的.为什么这可能不起作用的任何想法?我已经尝试了我能想到的所有内容,并阅读了我在这里找到的大部分帖子,但无济于事.
它没有崩溃,也没有给我任何迹象表明logcat中发生了什么,它什么也没做.
发送功能
private void sendFinishLog(String ID, String Cond)
{
Log.d("me", "send finish log");
Intent logIntent = new Intent();
logIntent.putExtra("ID", ID);
logIntent.putExtra("Cond", Cond);
logIntent.setAction("com.me.intent.finishlog");
Log.d("me","logIntent : " + logIntent.toString()
+logIntent.getExtras().toString());
sendBroadcast(logIntent);
}
Run Code Online (Sandbox Code Playgroud)
接受上课
public class LogReceiver extends BroadcastReceiver {
public static ArrayList<LogDataHolder> logData = new ArrayList<LogDataHolder>();
private boolean found;
static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
private static String lasttime;
private static String now = "Boot time";
@Override
public void onReceive(Context cont, Intent logIntent)
{
Log.d("me","On receive");
etc..... …
Run Code Online (Sandbox Code Playgroud) 我正在为令牌环LAN编写模拟,并尝试在主程序的单独线程中运行计时器,以检查从监视器接收到“活动状态”时是否超时。我在其他节点之前启动监视程序,并且它们在发送和“活动状态”或开始选举新监视器之前都具有相同的等待时间,但是节点程序似乎在监视器之前超时。
这仅仅是python中的并发性问题还是我的代码更可能有问题?
这是线程运行的功能,如果您需要更多信息,请询问
def timer():
global reset
global ismonitor
global mToSend
global dataToSend
reset = time.time()
send_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
while 1:
timer = time.time()
elapsed = timer - reset
if elapsed > 5:
if ismonitor:
mToSend = "110000" ## send around a token with a monitor alive flag on the broadcast channel
mToSend += maddr
dataToSend = True
reset = time.time()
else:
holdelection()
reset = time.time()
Run Code Online (Sandbox Code Playgroud) 我想编写一个bash脚本,它将在下一天的日期运行给定的但是过程数据,我当前的方法是获取unix时间戳并为其添加一些数秒的时间,但我无法让它工作,并且避风港还没找到我在网上寻找的东西.
这是我尝试过的,我觉得问题是它的字符串不是数字,但我不太了解bash确定,这是正确的吗?我该如何解决这个问题?
today="$(date +'%s')"
tomorrow="$($today + 86400)"
echo "$today"
echo "$tomorrow"
Run Code Online (Sandbox Code Playgroud)