是否可以覆盖关机操作?

时间:2019-02-17 14:40:47

标签: java android android-intent

我正在尝试修改或覆盖android中的电源关闭菜单按钮(而不是打开/关闭屏幕的按钮)的功能。

我想在设备关闭前触发一个进程,然后运行一个进程,然后再关闭设备

如果可能的话?

2 个答案:

答案 0 :(得分:0)

简单答案:

在有限数量的设备上,如果不对固件或Android操作系统的核心进行自定义修改,就不可能这样做。 More info

因此,在有根设备上,您可以执行此操作。 检查this链接。

答案 1 :(得分:0)

是的,有可能。您不必拥有植根设备就可以使用广播。 在清单中:

import Event from './vue-event.js';
import Buttons from './app-buttons.js';

export default Vue.component('post-item', {

	template: `
		<section class="posts flex" v-if="posts">
			<app-buttons :posts="posts" v-on:searchquery="update($event)"></app-buttons>

			<transition-group name="posts" tag="section" class="posts flex">
				<article class="postitem" :class="{ 'danger': !post.published }" v-for="post in filteredItems" :key="post.id">
					<p v-if="post.published">Post is published</p>
					<p v-else>Post is <em><strong>not</strong></em> published</p>
					<h4>{{ post.title }}</h4>

					<button type="submit" @click="post.published = !post.published">Change status</button>
				</article>
			</transition-group>
		</section>
	`,

	data() {
		return {
			search: '',
		};
	},

	components: {
		Buttons,
	},

	props: {
		posts: Array,
	},

	created() {
		console.log('%c Post items', 'font-weight: bold;color:blue;', 'created');
	},

	computed: {
		filteredItems(search) {
			return this.posts.filter(post => {
				return post.title.toLowerCase().indexOf(this.search.toLowerCase()) > -1
			});
		}
	},

	methods: {
		update(event) {
			this.search = event;
		}
	}
});



// Child component
import Event from './vue-event.js';

export default Vue.component('app-buttons', {
	template: `
		<div class="postswrapper flex flex--center flex--column">

			<section :class="className" class="flex flex--center">
				<button type="button" @click="showUnpublished">Unpublish</button>
				<button type="button" @click="shufflePosts">Shuffle</button>
			</section>

			<section :class="className">
				<input type="text" v-model="search" v-on:input="updateValue" placeholder="Search..." />
			</section>

		</div>
	`,

	data() {
		return {
			className: 'buttons',
			search: '',
		}
	},

	props: {
		posts: Array,
	},

	created() {
		console.log('%c Buttons', 'font-weight: bold;color:blue;', 'created');
	},

	methods: {
		updateValue() {
			this.$emit('searchquery', this.search);
		},

		showUnpublished() {
			this.posts.forEach(item => {
				item.published = true;
			})
		},
 
		shufflePosts() {
			for (var i = this.posts.length - 1; i >= 0; i--) {
				let random = Math.floor(Math.random() * i);
				let temp = this.posts[i];
				
				Vue.set(this.posts, i, this.posts[random]);
				Vue.set(this.posts, random, temp);
			}
		},
	}
});

您的班级:

Index same as before, just without alle the events on the components.

如果听起来不可能,请找到另一种做同一件事的方法;)