即使指定了android:screenOrientation =“ portrait”,Android在景观中的启动活动(来自库项目)

时间:2018-11-22 15:54:10

标签: android android-activity android-lifecycle

在我的应用中,我按以下顺序进行活动:

  • Activity1从startActivityForResult开始活动2
  • 活动2有时成功完成
  • onActivityResult中的Activity1中,活动2以startActivityForResult开始

所有活动均在清单中用android:screenOrientation="portrait"指定。

问题在于,当Activity2启动LibActivity时,手机处于横屏状态时,它最初是横屏启动,然后立即销毁并纵向创建。相反,当Activity1启动Activity2时,将以纵向创建Activity2。

关于LibActivity的唯一特定之处是它来自图书馆项目。

知道为什么会这样和/或如何避免吗?

在清单中声明活动的方式如下:

    <activity
        android:exported="false"
        android:name="com.test.LibActivity"
        android:screenOrientation="portrait">
    </activity>

图书馆只是我创建的图书馆项目。它包含在gradle中,例如:

implementation project(path: ':my_lib')

1 个答案:

答案 0 :(得分:0)

我发现问题是由

引起的
<?php include("includes/header.php");

    require("includes/function.php");
    require("language/language.php");
    require_once("thumbnail_images.class.php");



    if(isset($_POST['submit']))
    {   

      if(!empty($_POST['question']) && !empty($_POST['answer']))
      {


          $question = $_POST['question'];
          $answer = $_POST['answer'];
         $insertQry = "INSERT INTO `faq`( `question`, `answer`) VALUES ('$question','$answer')"; 
        mysqli_query($mysqli, $insertQry);
        $_SESSION['msg']="10"; 
        header( "Location:faq.php");
        exit;   
      }
 else {
        $_SESSION['msg']="10"; 
        header( "Location:add_faq.php");
        exit;   
 }

    }   


?>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$('#faq_type').on('change', function () {
     $("#upload").css('display', (this.value == '1' || this.value == '2') ? 'block' : 
      'none');
   }); 
</script>

       <div class="row">
      <div class="col-md-12">
        <div class="card">
          <div class="page_title_block">
            <div class="col-md-5 col-xs-12">
              <div class="page_title">Add FAQ</div>
            </div>
          </div>
          <div class="clearfix"></div>
          <div class="card-body mrg_bottom">
            <form class="form form-horizontal" action="" method="post"  enctype="multipart/form-data" onsubmit="return checkValidation(this);">
              <div class="section">
                <div class="section-body">

                <div class="form-group">
                    <label class="col-md-3 control-label">Category :-</label>
                    <div class="col-md-6">
                      <select name="faq_type" id="faq_type" class="select2" required>
                          <option value="0">Text</option>
                          <option value="1">Image</option>
                          <option value="2">Video</option>
                      </select>
                    </div>
                  </div>

                <div class="form-group" style="display:none;" id="upload">
                    <label class="col-md-3 control-label">Select Image/Video :-</label>
                    <div class="col-md-6">
                      <div class="fileupload_block" >
                        <input type="file" name="au_picture" value="fileupload" id="fileupload">
                        <?php if(isset($_GET['cat_id']) and $row['au_picture']!="") {?>
                              <div class="fileupload_img"><img type="image" src="images/<?php echo $row['au_picture'];?>" alt="category image" /></div>
                            <?php } else {?>
                              <div class="fileupload_img"><img type="image" src="assets/images/add-image.png" alt="category image" /></div>
                            <?php }?>
                      </div>
                    </div>
                </div>

                  <div class="form-group">
                    <div class="col-md-3">
                      <label class="control-label">Question :-</label>
                    </div>
                    <div class="col-md-6">
                     <textarea name="question" id="question" rows="1" class="form-control" ></textarea> 
                    </div>
                  </div>


                  <div class="form-group">
                    <div class="col-md-3">
                      <label class="control-label">Answer:-</label>
                    </div>
                    <div class="col-md-6">
                     <textarea name="answer" id="answer" rows="1" class="form-control" data-emojiable="true"></textarea> 
                    </div>
                  </div>

                  <div class="form-group">&nbsp;</div>
                  <div class="form-group">
                    <div class="col-md-9 col-md-offset-3">
                      <button type="submit" name="submit" class="btn btn-primary">Save</button>
                    </div>
                  </div>
                </div>
              </div>
            </form>
          </div>
        </div>
      </div>
    </div> 
<?php include("includes/footer.php");?>

为了避免过渡效果,我在开始活动时正在使用它。

显然,它会干扰人像锁定方向。