小编Bra*_*rad的帖子

恢复任务而不是特定活动的通知?

我有一个前台服务,只要用户登录到应用程序,就会保持与服务器的连接.这样即使用户按Home键将应用程序发送到后台,连接仍然保持活动并且可以直接从服务器接收消息.

该应用程序有许多活动,当它们被发送到后台时,其中任何活动都可以是活动的.

我想允许用户单击通知以恢复当前活动.我了解如何恢复特定活动,但想知道是否有办法恢复用户所在的最后一个活动?当然我可以跟踪最后一个,然后从Notification回调中调用它,但是认为在任务级别可能有办法?

感谢您提供的任何建议.

notifications android android-activity

28
推荐指数
3
解决办法
1万
查看次数

在嵌入式Linux平台上使用std :: string时出现Seg Fault

我已经在我的应用程序在嵌入式Arm Linux平台上运行的问题上工作了几天.不幸的是,该平台使我无法使用任何常用的有用工具来查找确切的问题.当在运行Linux的PC上运行相同的代码时,我没有遇到这样的错误.

在下面的示例中,我可以通过取消注释字符串,列表或矢量线来可靠地重现问题.让它们留下评论会导致应用程序运行完成.我希望有什么东西会破坏堆,但是我看不到什么?在发出分段错误之前,程序将运行几秒钟.

代码使用arm-linux交叉编译器编译:

arm-linux-g++ -Wall -otest fault.cpp -ldl -lpthread
arm-linux-strip test
Run Code Online (Sandbox Code Playgroud)

任何想法都非常感激.

#include <stdio.h>
#include <vector>
#include <list>
#include <string>

using namespace std;
/////////////////////////////////////////////////////////////////////////////

class TestSeg
{
 static pthread_mutex_t     _logLock;

 public:
  TestSeg()
  {
  }

  ~TestSeg()
  {
  }

  static void* TestThread( void *arg )
  {
   int i = 0;
   while ( i++ < 10000 )
   {
    printf( "%d\n", i );
    WriteBad( "Function" );
   }
   pthread_exit( NULL );
  }

  static void WriteBad( const char* sFunction )
  {
   pthread_mutex_lock( &_logLock );

   printf( …
Run Code Online (Sandbox Code Playgroud)

c++ linux string arm segmentation-fault

5
推荐指数
1
解决办法
1716
查看次数

线程安全的向量和字符串容器?

我发布了一个上一个问题"在嵌入式Linux平台上使用std :: string时出现Seg Fault",我得到了一些非常有用的建议.从那以后我就离开了其他项目,最近又回到了这个问题.

重申一下,我只能使用arm-linux交叉编译器(版本2.95.2),因为这是嵌入式平台供应商提供和支持的.我知道这个问题可能是因为stdlib非常老,而且特别是线程安全.

问题是每当我在多个线程中使用STL容器时,我最终会出现分段错误.除非我在容器声明周围使用pthread_mutex_lock和范围运算符(如在其他帖子中一样),否则下面的代码将始终是错误的.

在我的应用程序中使用这种方法是不可行的,因为我将容器传递给不同的方法和类.我理想地想解决这个问题,或者找一个合适的替代方案.我尝试过STLPort和SGI的标准模板库,结果相同.我只能假设因为它们是由非常古老的gcc链接的,所以它们无法解决问题.

有没有人有任何可能的建议或解决方案?或者你可以建议我可以放入我的代码中的vector(和string)的实现?

提前感谢任何指导.

#include <stdio.h>
  #include <vector>
  #include <list>
  #include <string>

  using namespace std;
    /////////////////////////////////////////////////////////////////////////////

    class TestSeg
    {
     static pthread_mutex_t     _logLock;
     public:
      TestSeg()
      {
      }

      ~TestSeg()
      {
      }

      static void* TestThread( void *arg )
      {
       int i = 0;
       while ( i++ < 10000 )
       {
        printf( "%d\n", i );
        WriteBad( "Function" );
       }
       pthread_exit( NULL );
      }

      static void WriteBad( const char* sFunction )
      {
       //pthread_mutex_lock( &_logLock );
       //{

       printf( "%s\n", …
Run Code Online (Sandbox Code Playgroud)

c++ linux arm stl segmentation-fault

2
推荐指数
1
解决办法
1601
查看次数